[英]how do i translate this C# attribute to VB
我是一个ASP MVC 3 noobie通过音乐商店教程工作,但将所有内容翻译成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
但编译器抛出错误(如上所示)。 好像认为错误信息是专辑的财产。
我该怎么做才能解决这个问题?
Public Class Album
<Required(ErrorMessage := "An Album Title is required")> _
<StringLength(160)> _
Public Property Title() As String
Get
Return m_Title
End Get
Set
m_Title = Value
End Set
End Property
Private m_Title As String
End Class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.