示例代码:

 

 ResourceManagerDemo
{
    /// <summary>
    
/// Summary description for Class1.
    
/// </summary>
    class Class1
    {
        
/// <summary>
        
/// The main entry point for the application.
        
/// </summary>
        [STAThread]
        
public static void Main() 
        {
            Console.WriteLine(GetResource(
"Welcome","en-us"));
            Console.WriteLine(GetResource(
"Welcome","zh-chs"));
        }
        
public static string GetResource(string name, string culture)
        {
            
// Create a resource manager to retrieve resources.
            
//Please notes that first parameter should be namespace+foldername+filename
            ResourceManager rm = new ResourceManager("ResourceManagerDemo.Resources.Strings", Assembly.GetExecutingAssembly());
            
// Get the culture of the currently executing thread.
            
// The value of ci will determine the culture of
            
// the resources that the resource manager retrieves.
            string resource = rm.GetString(name,new CultureInfo(culture));
            
return resource;
        }

    }
}

 

资源文件如下图:

使用ResourceManager实现多语言

相关文章:

  • 2022-01-28
  • 2021-05-28
  • 2021-12-18
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2021-08-16
猜你喜欢
  • 2021-09-05
  • 2023-03-14
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-08-29
  • 2021-09-03
相关资源
相似解决方案