本文整理汇总了C#中System.Resources.ResourceWriter类的典型用法代码示例。如果您正苦于以下问题:C# ResourceWriter类的具体用法?C# ResourceWriter怎么用?C# ResourceWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceWriter类属于System.Resources命名空间,在下文中一共展示了ResourceWriter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Resources;
public class WriteResources {
public static void Main(string[] args) {
// Creates a resource writer.
IResourceWriter writer = new ResourceWriter("myResources.resources");
// Adds resources to the resource writer.
writer.AddResource("String 1", "First String");
writer.AddResource("String 2", "Second String");
writer.AddResource("String 3", "Third String");
// Writes the resources to the file or stream, and closes it.
writer.Close();
}
}
示例2: new ResourceWriter
//引入命名空间
using System;
using System.Globalization;
using System.Resources;
using System.Collections;
class Class1 {
static void Main(string[] args) {
ResourceWriter resourceWriter = new ResourceWriter("Java2s.resources");
resourceWriter.AddResource("key 1", "First value");
resourceWriter.AddResource("key 2", "Second value");
resourceWriter.AddResource("key 3", "Third value");
resourceWriter.Generate();
resourceWriter.Close();
ResourceReader resourceReader = new ResourceReader("Java2s.resources");
IDictionaryEnumerator resourceReaderEn = resourceReader.GetEnumerator();
while (resourceReaderEn.MoveNext())
{
Console.WriteLine("Name: {0} - Value: {1}",
resourceReaderEn.Key.ToString().PadRight(10, ' '),
resourceReaderEn.Value);
}
resourceReader.Close();
}
}