当前位置: 首页>>代码示例>>C#>>正文


C# IniFile.SetString方法代码示例

本文整理汇总了C#中IniFile.SetString方法的典型用法代码示例。如果您正苦于以下问题:C# IniFile.SetString方法的具体用法?C# IniFile.SetString怎么用?C# IniFile.SetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IniFile的用法示例。


在下文中一共展示了IniFile.SetString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test


//.........这里部分代码省略.........
        AssertEqual(testIni1.count,        2);
        AssertEqual(testIni1.keys.Count,   2);
        AssertEqual(testIni1.values.Count, 2);
        AssertEqual(testIni1.currentGroup, "Group 1/");

        testIni1.SetBool("Subgroup 1/Key 4",  true);

        AssertEqual(testIni1.count,        3);
        AssertEqual(testIni1.keys.Count,   3);
        AssertEqual(testIni1.values.Count, 3);
        AssertEqual(testIni1.currentGroup, "Group 1/");

        testIni1.EndGroup();

        AssertEqual(testIni1.count,        4);
        AssertEqual(testIni1.keys.Count,   4);
        AssertEqual(testIni1.values.Count, 4);
        AssertEqual(testIni1.currentGroup, "");

        testIni1.SetByteArray("Group 2/Key 5",  testBytes);

        AssertEqual(testIni1.count,        5);
        AssertEqual(testIni1.keys.Count,   5);
        AssertEqual(testIni1.values.Count, 5);
        AssertEqual(testIni1.currentGroup, "");

        testIni1.Set("Group 2/Subgroup 1/Key 6", testPair);

        AssertEqual(testIni1.count,        6);
        AssertEqual(testIni1.keys.Count,   6);
        AssertEqual(testIni1.values.Count, 6);
        AssertEqual(testIni1.currentGroup, "");

        testIni1.SetString("Group 2/Subgroup 2/Key 7", "Hello World!\t");

        //testIni1.EndGroup(); // To check for error

        AssertEqual(testIni1.count,        7);
        AssertEqual(testIni1.keys.Count,   7);
        AssertEqual(testIni1.values.Count, 7);
        AssertEqual(testIni1.currentGroup, "");

        keys   = testIni1.keys;
        values = testIni1.values;

        AssertEqual(keys[0], "Key 1");
        AssertEqual(keys[1], "Group 1/Key 2");
        AssertEqual(keys[2], "Group 1/Subgroup 1/Key 3");
        AssertEqual(keys[3], "Group 1/Subgroup 1/Key 4");
        AssertEqual(keys[4], "Group 2/Key 5");
        AssertEqual(keys[5], "Group 2/Subgroup 1/Key 6");
        AssertEqual(keys[6], "Group 2/Subgroup 2/Key 7");

        AssertEqual(values[0].key, "Key 1");
        AssertEqual(values[1].key, "Group 1/Key 2");
        AssertEqual(values[2].key, "Group 1/Subgroup 1/Key 3");
        AssertEqual(values[3].key, "Group 1/Subgroup 1/Key 4");
        AssertEqual(values[4].key, "Group 2/Key 5");
        AssertEqual(values[5].key, "Group 2/Subgroup 1/Key 6");
        AssertEqual(values[6].key, "Group 2/Subgroup 2/Key 7");

        AssertEqual(values[0].value, "1");
        AssertEqual(values[1].value, "0.2");
        AssertEqual(values[2].value, "0.3");
        AssertEqual(values[3].value, "True");
        AssertEqual(values[4].value, "010204080F235DA7D8");
开发者ID:Gris87,项目名称:IniFile,代码行数:67,代码来源:IniFile_DemoScript.cs


注:本文中的IniFile.SetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。