当前位置: 首页>>代码示例>>C#>>正文


C# ResXResourceWriter类代码示例

本文整理汇总了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);  
      }
   }
}
开发者ID:.NET开发者,项目名称:System.Resources,代码行数:70,代码来源:ResXResourceWriter

示例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();
   }
}
开发者ID:C#程序员,项目名称:System.Resources,代码行数:33,代码来源:ResXResourceWriter


注:本文中的System.Resources.ResXResourceWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。