本文整理汇总了C#中System.Resources.ResXResourceWriter类的典型用法代码示例。如果您正苦于以下问题:C# ResXResourceWriter类的具体用法?C# ResXResourceWriter怎么用?C# ResXResourceWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResXResourceWriter类属于System.Resources命名空间,在下文中一共展示了ResXResourceWriter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Automobile
//引入命名空间
using System;
using System.Drawing;
using System.Resources;
[Serializable()] public class Automobile
{
private string carMake;
private string carModel;
private int carYear;
private int carDoors;
private int carCylinders;
public Automobile(string make, string model, int year) :
this(make, model, year, 0, 0)
{ }
public Automobile(string make, string model, int year,
int doors, int cylinders)
{
this.carMake = make;
this.carModel = model;
this.carYear = year;
this.carDoors = doors;
this.carCylinders = cylinders;
}
public string Make {
get { return this.carMake; }
}
public string Model {
get {return this.carModel; }
}
public int Year {
get { return this.carYear; }
}
public int Doors {
get { return this.carDoors; }
}
public int Cylinders {
get { return this.carCylinders; }
}
}
public class Example
{
public static void Main()
{
// Instantiate an Automobile object.
Automobile car1 = new Automobile("Ford", "Model N", 1906, 0, 4);
Automobile car2 = new Automobile("Ford", "Model T", 1909, 2, 4);
// Define a resource file named CarResources.resx.
using (ResXResourceWriter resx = new ResXResourceWriter(@".\CarResources.resx"))
{
resx.AddResource("Title", "Classic American Cars");
resx.AddResource("HeaderString1", "Make");
resx.AddResource("HeaderString2", "Model");
resx.AddResource("HeaderString3", "Year");
resx.AddResource("HeaderString4", "Doors");
resx.AddResource("HeaderString5", "Cylinders");
resx.AddResource("Information", SystemIcons.Information);
resx.AddResource("EarlyAuto1", car1);
resx.AddResource("EarlyAuto2", car2);
}
}
}
示例2: new ResXResourceWriter
//引入命名空间
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();
}
}