本文整理汇总了C#中IniFile.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IniFile.ToString方法的具体用法?C# IniFile.ToString怎么用?C# IniFile.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IniFile
的用法示例。
在下文中一共展示了IniFile.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
private void Test()
{
IniFile.KeyPair testPair = new IniFile.KeyPair("1", "2", "3");
IniFile testIni1 = new IniFile();
IniFile testIni2 = new IniFile();
ReadOnlyCollection<string> keys;
ReadOnlyCollection<IniFile.KeyPair> values;
byte[] testBytes = new byte[] { 1, 2, 4, 8, 15, 35, 93, 167, 216 };
#region IniFile.KeyPair
#region IniFile.KeyPair.Equals
AssertEqual(testPair.Equals(null), false);
AssertEqual(testPair.Equals(testPair), true);
AssertEqual(testPair.Equals("Hello World"), false);
AssertEqual(testPair.Equals(new IniFile.KeyPair("1", "2", "3")), true);
AssertEqual(new IniFile.KeyPair("1", "2", "3").Equals(testPair), true);
AssertEqual(new IniFile.KeyPair("1", "2", "3"), new IniFile.KeyPair("1", "2", "3"));
#endregion
// ---------------------------------------------------------------------------------
#region IniFile.KeyPair.ToString
AssertEqual(new IniFile.KeyPair("1", "2", "3").ToString(), "[KeyPair: key=1, value=2, comment=3]");
#endregion
#endregion
// ===================================================================================
#region IniFile
#region IniFile constructor
AssertEqual(testIni1.count, 0);
AssertEqual(testIni1.keys.Count, 0);
AssertEqual(testIni1.values.Count, 0);
AssertEqual(testIni1.currentGroup, "");
AssertEqual(testIni1.ToString(), "");
AssertEqual(testIni1, testIni2);
#endregion
// ---------------------------------------------------------------------------------
#region IniFile Set function
testIni1.Set("Key 1", 1);
testIni1.Set("Key 2", 2, "Comment 2");
testIni1.Set("Key 3", 0.1f);
testIni1.Set("Key 4", 0.2f, "Comment 4");
testIni1.Set("Key 5", 0.1);
testIni1.Set("Key 6", 0.2, "Comment 6");
testIni1.Set("Key 7", true);
testIni1.Set("Key 8", false, "Comment 8");
testIni1.Set("Key 9", testBytes);
testIni1.Set("Key 10", testBytes, "Comment 10");
testIni1.Set("Key 11", testPair);
testIni1.Set("Key 12", testPair, "Comment 12");
testIni1.Set("Key 13", " Hello");
testIni1.Set("Key 14", "World ", "Comment 14");
AssertEqual(testIni1.count, 14);
AssertEqual(testIni1.keys.Count, 14);
AssertEqual(testIni1.values.Count, 14);
AssertEqual(testIni1.currentGroup, "");
keys = testIni1.keys;
values = testIni1.values;
for (int i = 0; i < 14; ++i)
{
AssertEqual(keys[i], "Key " + (i + 1));
AssertEqual(values[i].key, "Key " + (i + 1));
}
AssertEqual(values[0].value, "1");
AssertEqual(values[1].value, "2");
AssertEqual(values[2].value, "0.1");
AssertEqual(values[3].value, "0.2");
AssertEqual(values[4].value, "0.1");
AssertEqual(values[5].value, "0.2");
AssertEqual(values[6].value, "True");
AssertEqual(values[7].value, "False");
AssertEqual(values[8].value, "010204080F235DA7D8");
AssertEqual(values[9].value, "010204080F235DA7D8");
AssertEqual(values[10].value, "[KeyPair: key=1, value=2, comment=3]");
AssertEqual(values[11].value, "[KeyPair: key=1, value=2, comment=3]");
AssertEqual(values[12].value, " Hello");
AssertEqual(values[13].value, "World ");
AssertEqual(values[0].comment, "");
AssertEqual(values[1].comment, "Comment 2");
AssertEqual(values[2].comment, "");
AssertEqual(values[3].comment, "Comment 4");
AssertEqual(values[4].comment, "");
AssertEqual(values[5].comment, "Comment 6");
AssertEqual(values[6].comment, "");
AssertEqual(values[7].comment, "Comment 8");
AssertEqual(values[8].comment, "");
AssertEqual(values[9].comment, "Comment 10");
AssertEqual(values[10].comment, "");
AssertEqual(values[11].comment, "Comment 12");
AssertEqual(values[12].comment, "");
//.........这里部分代码省略.........