本文整理汇总了C#中Dictionary.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.ToString方法的具体用法?C# Dictionary.ToString怎么用?C# Dictionary.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary
的用法示例。
在下文中一共展示了Dictionary.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTownBuild
public void OnTownBuild(Town sender)
{
_buildedTowns.Add(sender.gameObject);
sender.OnActivate += new Town.OnActivateContainer(OnTownActivate);
var cardsTypes = new Dictionary<ResourceType, int>();
switch (sender.Type) {
case TownType.Village:
cardsTypes.Add(ResourceType.Brick,1);
cardsTypes.Add(ResourceType.Hay,1);
cardsTypes.Add(ResourceType.Wood,1);
cardsTypes.Add(ResourceType.Wool,1);
break;
case TownType.Town:
cardsTypes.Add(ResourceType.Hay,2);
cardsTypes.Add(ResourceType.Stone,3);
break;
}
Debug.Log(cardsTypes.ToString());
var cards = playerDeck.GetComponent<PlayerDeck>().GetCards(cardsTypes);
Debug.Log(cards.Count);
cards.ForEach(delegate(ResourceCard card) {
var deck = decksController.GetComponent<DecksController>().GetDeck(card.ResourceType);
card.ReturnCardToDeck(deck);
});
}
示例2: TestDictionaryToString
public void TestDictionaryToString()
{
TestClass testclass = new TestClass() { ID = 5, Decimal = 3.3M, Float = 3.23423F, String = "blah, \"asdff\"" };
testclass.Class = new TestClass() { ID = 5, Decimal = 3.3M, Float = 3.23423F, String = "blah, \"asdff\"" };
Dictionary<int, TestClass> lst = new Dictionary<int, TestClass>();
for (int i = 0; i < 2; i++)
{
lst.Add(i, testclass);
}
string actual = lst.ToString(',');
Assert.AreEqual("0,\"5,\"blah, \"\"asdff\"\"\",3.3,3.23423,\"5,\"blah, \"\"asdff\"\"\",3.3,3.23423\"\"\r\n1,\"5,\"blah, \"\"asdff\"\"\",3.3,3.23423,\"5,\"blah, \"\"asdff\"\"\",3.3,3.23423\"\"\r\n", actual);
}
开发者ID:nathanjuett,项目名称:com.ParttimeSoftware.HelpersThatShouldAlreadyBeThere,代码行数:12,代码来源:HelpersTest.cs
示例3: GetOrAdd
public void GetOrAdd()
{
var d = new Dictionary<string, StockStatus>() {
{"AAPL", new StockStatus { Price = 530.12m, Position = "Sell" }},
{"GOOG", new StockStatus { Price = 123.5m, Position = "Buy" }}
};
d.GetOrAdd("AAPL").Position = "Buy";
d.GetOrAdd("YHOO").Price = 1.99m;
Console.Out.WriteLine(d.ToString<string, StockStatus>());
Assert.That(d["AAPL"].Position, Is.EqualTo("Buy"), "Incorrect position.");
Assert.That(d.Keys, Has.Count.EqualTo(3), "Incorrect number of keys.");
Assert.That(d["YHOO"].Price, Is.EqualTo(1.99m), "Incorrect price.");
}
示例4: RpcCall
public static string RpcCall(string url, string method, Dictionary<string, string> args)
{
string result = string.Empty;
try
{
PHPRPC_Client rpc = new PHPRPC_Client(url);
IPhprpc p = (IPhprpc)rpc.UseService(typeof(IPhprpc));
result = p.data(method, args);
}
catch(Exception ex)
{
string error = string.Format("Exception in RpcCall():{0}, url = {1}, method={2}, args={3}", ex.ToString(), url, method, args.ToString());
}
return result;
}
示例5: UpdateVersionFile
public static void UpdateVersionFile(Dictionary<string, string> version, string versionFilePath)
{
try
{
FileStream versionFile = new FileStream(versionFilePath, FileMode.OpenOrCreate);
foreach (string fileName in version.Keys)
{
string nameHashPair = fileName + "," + version[fileName] + ";";
versionFile.Write(System.Text.Encoding.ASCII.GetBytes(nameHashPair), 0, System.Text.Encoding.ASCII.GetByteCount(nameHashPair));
}
versionFile.Close();
}
catch (Exception e)
{
Utils.configLog("E", e.Message + ". UpdateVersionFile, version: " + version.ToString());
}
}
示例6: GetShortestPath
public List<Coordinate> GetShortestPath(Coordinate start, Coordinate goal)
{
HashSet<Coordinate> visited = new HashSet<Coordinate>();
Dictionary<Coordinate, Coordinate> parents = new Dictionary<Coordinate, Coordinate>();
Dictionary<Coordinate, double> gScore = new Dictionary<Coordinate, double>();
HeapPriorityQueue<Coordinate> fScoreQueue = new HeapPriorityQueue<Coordinate>(rows * cols);
parents[start] = start;
gScore.Add(start, 0);
fScoreQueue.Enqueue(start, gScore[start] + Heuristic(start, goal));
while (fScoreQueue.Count() != 0)
{
Coordinate current = fScoreQueue.Dequeue();
Console.Out.WriteLine("");
Console.Out.WriteLine("Current = " + current.ToString());
Console.Out.WriteLine("Visited = " + visited.ToString());
Console.Out.WriteLine("Parents = " + parents.ToString());
Console.Out.WriteLine("gScore = " + gScore.ToString());
Console.Out.WriteLine("fScoreQueue = " + fScoreQueue.ToString());
if (current == goal)
{
return ReconstructPath(parents, goal);
}
visited.Add(start);
foreach (Coordinate neighbor in board[current.row,current.col].GetNeighborCoordinates())
{
if (visited.Contains(neighbor)) continue;
double newGScore = gScore[current] + Distance(current, neighbor);
if (!fScoreQueue.Contains(neighbor))
{
parents[neighbor] = current;
gScore[neighbor] = newGScore;
fScoreQueue.Enqueue(neighbor, newGScore + Heuristic(neighbor, goal));
}
else if (newGScore < gScore[neighbor])
{
parents[neighbor] = current;
gScore[neighbor] = newGScore;
fScoreQueue.UpdatePriority(neighbor, newGScore + Heuristic(neighbor, goal));
}
}
}
return null;
}
示例7: PostData
public string PostData(string url, Dictionary<string, string> data, Encoding encoding = null)
{
var http = CreateNewRequest(url, "POST");
http.ContentType = "application/x-www-form-urlencoded";
if(encoding == null) encoding = new UTF8Encoding();
var outgoingQueryString = HttpUtility.ParseQueryString(string.Empty);
foreach (var item in data)
{
outgoingQueryString.Add(item.Key, item.Value);
}
PostBytes(data.ToString(), encoding, http);
return ReadResponse(http, encoding);
}
示例8: ChampionListStatic
public ChampionListStatic(string data,
string format,
JObject keys,
string type,
string version,
JObject originalObject)
{
this.data = new Dictionary<string, ChampionStatic>();
this.keys = new Dictionary<string, string>();
LoadData(data);
this.format = format;
if (keys != null)
{
this.keys = JsonConvert.DeserializeObject<Dictionary<string, string>>(keys.ToString());
}
this.type = type;
this.version = version;
this.originalObject = originalObject;
}
示例9: getDTD
public SgmlDtd getDTD(String version, String DTD)
{
if (log.IsDebugEnabled) log.Debug("getDTD(version: " + version + ", DTD: " + DTD + ")");
SgmlReader reader = null;
Dictionary<String, SgmlDtd> dtd = null;
if (this.checkAvailableVersion(DTD+version) && !this.version.ContainsKey(version)) {
reader = new SgmlReader();
reader.CaseFolding = Sgml.CaseFolding.ToLower;
String sgmlArticle = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.availableVersion[DTD+version]);
if (log.IsDebugEnabled) log.Debug("sgmlArticle: " + sgmlArticle);
reader.SystemLiteral = sgmlArticle;
dtd = new Dictionary<String, SgmlDtd>();
dtd.Add(DTD, reader.Dtd);
if (log.IsDebugEnabled) log.Debug("dtd.Add(DTD: " + DTD + ", reader.Dtd: " + reader.Dtd.ToString() + ")");
this.version.Add(version, dtd);
if (log.IsDebugEnabled) log.Debug("this.version.Add(version: " + version + ", dtd: " + dtd.ToString() + ")");
}
if (log.IsDebugEnabled) log.Debug("return this.version[version: " + version + "][DTD: " + DTD + "]");
return this.version[version][DTD];
}
示例10: Main
public static void Main(string[] args)
{
Console.WriteLine("*****开始发送******");
JSMSClient client = new JSMSClient(app_key, master_secret);
// 短信验证码 API
// API文档地址 http://docs.jiguang.cn/jsms/server/rest_api_jsms/#api_3
Dictionary<string, string> temp_para= new Dictionary<string, string>(); ;
temp_para.Add("codes", "1914");
string para = temp_para.ToString();
Console.WriteLine(para);
SMSPayload codes = new SMSPayload("134888888888", 9890, temp_para);
String codesjson = codes.ToJson(codes);
Console.WriteLine(codesjson);
client._SMSClient.sendMessages(codesjson);
Console.ReadLine();
}
示例11: ProcessPushNotification
public void ProcessPushNotification(Dictionary <string, string> data)
{
System.Diagnostics.Debug.WriteLine ("Received a push notification " + data.ToString());
MessagingCenter.Send<Xamarin.Forms.Application> (App.Current, "refresh_menu");
}
示例12: BasicDataStatic
public BasicDataStatic(string colloq,
bool? consumeOnFull,
bool? consumed,
int? depth,
string description,
JArray fromA,
JObject goldO,
string group,
bool? hideFromAll,
int id,
JObject imageO,
bool? inStore,
JArray intoA,
JObject maps,
string name,
string plainText,
string requiredChampion,
JObject runeO,
string sanitizedDescription,
int? specialRecipe,
int? stacks,
JObject statsO,
JArray tagsA)
{
from = new List<string>();
into = new List<string>();
this.maps = new Dictionary<string, bool>();
tags = new List<string>();
this.colloq = colloq;
this.consumeOnFull = consumeOnFull;
this.consumed = consumed;
this.depth = depth;
this.description = description;
if (fromA != null)
{
this.from = HelperMethods.LoadStrings(fromA);
}
if (goldO != null)
{
LoadGold(goldO);
}
this.group = group;
this.hideFromAll = hideFromAll;
this.id = id;
if (imageO != null)
{
this.image = HelperMethods.LoadImageStatic(imageO);
}
this.inStore = inStore;
if (intoA != null)
{
this.into = HelperMethods.LoadStrings(intoA);
}
if (maps != null)
{
this.maps = JsonConvert.DeserializeObject<Dictionary<string, bool>>(maps.ToString());
}
this.name = name;
this.plainText = plainText;
this.requiredChampion = requiredChampion;
if (runeO != null)
{
this.rune = HelperMethods.LoadMetaDataStatic(runeO);
}
this.sanitizedDescription = sanitizedDescription;
this.stacks = stacks;
if (statsO != null)
{
LoadBasicDataStats(statsO);
}
if (tagsA != null)
{
this.tags = HelperMethods.LoadStrings(tagsA);
}
}
示例13: UpdateCurrentVersionFile
private void UpdateCurrentVersionFile(Dictionary<string, string> version)
{
try
{
Utils.DeleteFile(logger, Settings.ConfigDir + "\\" + CurrentVersionFileName);
FileStream versionFile = new FileStream(Settings.ConfigDir + "\\" + CurrentVersionFileName, FileMode.OpenOrCreate);
foreach (string fileName in version.Keys)
{
string nameHashPair = fileName + "," + version[fileName] + ";";
versionFile.Write(System.Text.Encoding.ASCII.GetBytes(nameHashPair), 0, System.Text.Encoding.ASCII.GetByteCount(nameHashPair));
}
versionFile.Close();
}
catch (Exception e)
{
Utils.structuredLog(logger, "E", e.Message + ". UpdateCurrentVersionFile, version: " + version.ToString());
}
}
示例14: var_types
public void var_types(int param)
{
WriteXmlAndXslFiles();
object t = null;
switch (param)
{
case 1: t = Tuple.Create(1, "Melitta", 7.5); break;
//case 2: t = new TestDynamicObject(); break;
case 3: t = new Guid(); break;
case 4: t = new Dictionary<string, object>(); break;
}
_output.WriteLine(t.ToString());
#pragma warning disable 0618
XslTransform xslt = new XslTransform();
#pragma warning restore 0618
xslt.Load("type.xsl");
XsltArgumentList xslArg = new XsltArgumentList();
xslArg.AddParam("param", "", t);
xslArg.AddExtensionObject("", t);
XPathDocument xpathDom = new XPathDocument("type.xml");
using (StringWriter sw = new StringWriter())
{
xslt.Transform(xpathDom, xslArg, sw);
_output.WriteLine(sw.ToString());
}
return;
}
示例15: UpdateRow
public override string UpdateRow()
{
LogCallMethod(true);
string returnID = string.Empty;
using (SqlConnection con = new SqlConnection(DataServices.ConnectString))
{
con.Open();
SqlTransaction sqlTran = con.BeginTransaction();
try
{
Dictionary<string, object> SALE_movingValues = new Dictionary<string, object>
{
{"stockMovingNo", ctrlMa.Text},
{"fromStockID",cmbfromStock.Value},
{"toStockID",cmbtoStock.Value},
{"fromStockStaffID",cmbfromStaff.Value},
{"toStockStaffID",cmbtoStaff.Value},
{"notes", txtNotes.Text},
{"quantity",CU.GetSpinValue(totalQuantity)},
{"dateMoved", CU.GetDateEditValue(dtorderdate)}
};
//lay invoiceID cua SALE_invoice
var stockMovingKey = new Dictionary<string, object>
{
{"stockMovingID",globalID}
};
EU.updateTblScript(sqlTran, "SM_moving", SALE_movingValues, stockMovingKey);
var movingWheres = new Dictionary<string, object>
{
{"sessionKey", globalSessionKey},
};
var mappingSALE_temptoSM_moving_details = new Dictionary<string, object>
{ //Details ====== temp
{"productID", "productID"},
{"currentPrice", "currentPrice"},
{"quantity", "quantity"},
{"note","notes"},
{"orderNum", "oderNumber"},
{"boID", "boID"},
{"userID", "userID"},
{"dateCreated", "dateCreated"},
{"sessionKey", "sessionKey"}
};
EU.MovingTableTemToDetails(sqlTran, "SM_moving_details", "SALE_temp", stockMovingKey, mappingSALE_temptoSM_moving_details, movingWheres, true);
sqlTran.Commit();
returnID = stockMovingKey.ToString();
}
catch (Exception ex)
{
sqlTran.Rollback();
LogAction(0, ex.ToString());
returnID = "error - " + ex.ToString();
}
}
LogCallMethod(false);
return returnID;
}