本文整理汇总了C#中System.Resources.ResXResourceReader.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# ResXResourceReader.GetEnumerator方法的具体用法?C# ResXResourceReader.GetEnumerator怎么用?C# ResXResourceReader.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resources.ResXResourceReader
的用法示例。
在下文中一共展示了ResXResourceReader.GetEnumerator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Collections;
using System.Resources;
public class Example
{
private const string resxFilename = @".\CountryHeaders.resx";
public static void Main()
{
// Create a resource file to read.
CreateResourceFile();
// Enumerate the resources in the file.
ResXResourceReader rr = new ResXResourceReader(resxFilename);
IDictionaryEnumerator dict = rr.GetEnumerator();
while (dict.MoveNext())
Console.WriteLine("{0}: {1}", dict.Key, dict.Value);
}
private static void CreateResourceFile()
{
ResXResourceWriter rw = new ResXResourceWriter(resxFilename);
string[] resNames = {"Country", "Population", "Area",
"Capital", "LCity" };
string[] columnHeaders = { "Country Name", "Population (2010}",
"Area", "Capital", "Largest City" };
string[] comments = { "The localized country name", "",
"The area in square miles", "",
"The largest city based on 2010 data" };
rw.AddResource("Title", "Country Information");
rw.AddResource("nColumns", resNames.Length);
for (int ctr = 0; ctr < resNames.Length; ctr++) {
ResXDataNode node = new ResXDataNode(resNames[ctr], columnHeaders[ctr]);
node.Comment = comments[ctr];
rw.AddResource(node);
}
rw.Generate();
rw.Close();
}
}
输出:
Title: Country Information nColumns: 5 Country: Country Name Population: Population (2010} Area: Area Capital: Capital LCity: Largest City
示例2: ResXResourceReader.GetEnumerator()
//引入命名空间
using System;
using System.Globalization;
using System.Resources;
using System.Collections;
using System.Drawing;
class Class1 {
static void Main(string[] args) {
ResXResourceWriter RwX = new ResXResourceWriter("Java2s.resx");
RwX.AddResource("key 1", "First value");
RwX.AddResource("key 2", "Second value");
RwX.AddResource("key 3", "Third value");
// add an image to the resource file
Image img = Image.FromFile("winter.jpg");
RwX.AddResource("winter.jpg", img);
RwX.Generate();
RwX.Close();
ResXResourceReader RrX = new ResXResourceReader("Java2s.resx");
IDictionaryEnumerator RrEn = RrX.GetEnumerator();
while (RrEn.MoveNext())
{
Console.WriteLine("Name: {0} - Value: {1}",
RrEn.Key.ToString().PadRight(10, ' '),
RrEn.Value);
}
RrX.Close();
}
}