我是一个 ASP MVC 3 新手,通过音乐商店教程工作,但将所有内容都翻译成 VB(我在 VB 商店工作)。
该教程有一行:
public class Album
{
[Required(ErrorMessage = "An Album Title is required")]
[StringLength(160)]
public string Title { get; set; }
}
我如何将它翻译成VB?显而易见的选择是:
Public Class Album
<Required(ErrorMessage = "Price is required")> //Compiler says:'ErrorMessage' is not declared. It may be inaccessible due to its protection level.
<StringLength(160)>
Property Title As String
Property Price As Decimal
End Class
但是编译器抛出错误(如上所示)。似乎认为错误消息是专辑的属性。
我能做些什么来解决这个问题?