Csharp/C Sharp by API/System.Resources/ResourceSet

Материал из .Net Framework эксперт
Версия от 12:12, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

new ResourceSet

 

using System;
using System.Globalization;
using System.Resources;
using System.Collections;
class Class1 {
  static void Main(string[] args) {
      ResourceWriter resourceWriter = new ResourceWriter("nfex.resources");
      resourceWriter.AddResource("key 1", "First value");
      resourceWriter.AddResource("key 2", "Second value");
      resourceWriter.AddResource("key 3", "Third value");
      resourceWriter.Generate();
      resourceWriter.Close();
      ResourceSet Rs = new ResourceSet("nfex.resources");
      Console.WriteLine(Rs.GetString("key 1 ", true));
      Console.WriteLine(Rs.GetString("key 2", true));
      Console.WriteLine(Rs.GetString("key 3", true));
      Console.WriteLine(Rs.GetDefaultReader().ToString());
      Rs.Close();
   }
}


ResourceSet.GetDefaultReader()

 

using System;
using System.Globalization;
using System.Resources;
using System.Collections;
class Class1 {
  static void Main(string[] args) {
      ResourceWriter resourceWriter = new ResourceWriter("nfex.resources");
      resourceWriter.AddResource("key 1", "First value");
      resourceWriter.AddResource("key 2", "Second value");
      resourceWriter.AddResource("key 3", "Third value");
      resourceWriter.Generate();
      resourceWriter.Close();
      ResourceSet Rs = new ResourceSet("nfex.resources");
      Console.WriteLine(Rs.GetString("key 1 ", true));
      Console.WriteLine(Rs.GetString("key 2", true));
      Console.WriteLine(Rs.GetString("key 3", true));
      Console.WriteLine(Rs.GetDefaultReader().ToString());
      Rs.Close();
   }
}


ResourceSet.GetString

 

using System;
using System.Globalization;
using System.Resources;
using System.Collections;
class Class1 {
  static void Main(string[] args) {
      ResourceWriter resourceWriter = new ResourceWriter("nfex.resources");
      resourceWriter.AddResource("key 1", "First value");
      resourceWriter.AddResource("key 2", "Second value");
      resourceWriter.AddResource("key 3", "Third value");
      resourceWriter.Generate();
      resourceWriter.Close();
      ResourceSet Rs = new ResourceSet("nfex.resources");
      Console.WriteLine(Rs.GetString("key 1 ", true));
      Console.WriteLine(Rs.GetString("key 2", true));
      Console.WriteLine(Rs.GetString("key 3", true));
      Console.WriteLine(Rs.GetDefaultReader().ToString());
      Rs.Close();
   }
}