本文整理汇总了C#中System.Resources.ResourceWriter.Generate方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceWriter.Generate方法的具体用法?C# ResourceWriter.Generate怎么用?C# ResourceWriter.Generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resources.ResourceWriter
的用法示例。
在下文中一共展示了ResourceWriter.Generate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Resources;
using System.IO;
public class WriteResources
{
public static void Main(string[] args)
{
// Create a file stream to encapsulate items.resources.
FileStream fs = new FileStream("items.resources",
FileMode.OpenOrCreate,FileAccess.Write);
// Open a resource writer to write from the stream.
IResourceWriter writer = new ResourceWriter(fs);
// Add resources to the resource writer.
writer.AddResource("String 1", "First String");
writer.AddResource("String 2", "Second String");
writer.AddResource("String 3", "Third String");
// Generate the resources, and close the writer.
writer.Generate();
writer.Close();
}
}
示例2: ResourceWriter.Generate()
//引入命名空间
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();
}
}