【发布时间】:2019-07-05 23:35:24
【问题描述】:
使用DisplayAttribute 可以直接本地化类的属性。
当尝试使用资源文件EmployeeResx.resx , EmployeeResx.fr.res...., 本地化属性时,静态类EmployeeResx.Designer.cs 会生成静态字符串属性,例如:
public static string LastName {
get {
return ResourceManager.GetString("LastName", resourceCulture);
}
}
尝试使用静态字符串本地化属性(本例中为选项)的属性,如:
[Option('l', "lastname", HelpText = EmployeeResx.LastName)]
public string LastName { get; set; }
c#编译器报错:
错误 CS0182 属性参数必须是属性参数类型的常量表达式、typeof 表达式或数组创建表达式
有很多属性需要本地化。
如何像上例一样本地化属性的字符串属性?
【问题讨论】:
标签: c# localization attributes resx