为什么我不能将DisplayAttribute与Global Resource文件一起使用?

Cus*_*dio 0 c# asp.net resources

问题已经解释了我正在尝试做什么,这是一个例子:

[Display(Name = Localization.City)]
public string City { get; set; }
Run Code Online (Sandbox Code Playgroud)

错误是,但(对我来说)没有意义:属性参数必须是属性参数类型的常量表达式,typeof表达式或数组创建表达式

STO*_*STO 6

要将DisplayAttribute与您需要使用的资源一起使用

[Display(ResourceType=typeof(Localization), Name="City")]
public string City {get;set;}
Run Code Online (Sandbox Code Playgroud)

并且不要忘记打开资源文件并将访问修饰符设置为public而不是internal.