本文整理汇总了C#中System.Resources.ResXResourceSet类的典型用法代码示例。如果您正苦于以下问题:C# ResXResourceSet类的具体用法?C# ResXResourceSet怎么用?C# ResXResourceSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResXResourceSet类属于System.Resources命名空间,在下文中一共展示了ResXResourceSet类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Collections;
using System.Drawing;
using System.Resources;
public class Example
{
public static void Main()
{
CreateResXFile();
ResXResourceSet resSet = new ResXResourceSet(@".\StoreResources.resx");
IDictionaryEnumerator dict = resSet.GetEnumerator();
while (dict.MoveNext()) {
string key = (string) dict.Key;
// Retrieve resource by name.
if (dict.Value is string)
Console.WriteLine("{0}: {1}", key, resSet.GetString(key));
else
Console.WriteLine("{0}: {1}", key, resSet.GetObject(key));
}
}
private static void CreateResXFile()
{
Bitmap logo = new Bitmap(@".\Logo.bmp");
ResXDataNode node;
ResXResourceWriter rw = new ResXResourceWriter(@".\StoreResources.resx");
node = new ResXDataNode("Logo", logo);
node.Comment = "The corporate logo.";
rw.AddResource(node);
rw.AddResource("AppTitle", "Store Locations");
node = new ResXDataNode("nColumns", 5);
node.Comment = "The number of columns in the Store Location table";
rw.AddResource(node);
rw.AddResource("City", "City");
rw.AddResource("State", "State");
rw.AddResource("Code", "Zip Code");
rw.AddResource("Telephone", "Phone");
rw.Generate();
rw.Close();
}
}
输出:
Telephone: Phone Code: Zip Code State: State City: City nColumns: 5 AppTitle: Store Locations Logo: System.Drawing.Bitmap