[英]how do i translate this C# attribute to VB
I am an ASP MVC 3 noobie working my way thru the music store tutorial, but translating everything into VB (I work in a VB shop). 我是一个ASP MVC 3 noobie通过音乐商店教程工作,但将所有内容翻译成VB(我在VB商店工作)。
The tutorial has a line: 本教程有一行:
public class Album
{
[Required(ErrorMessage = "An Album Title is required")]
[StringLength(160)]
public string Title { get; set; }
}
How do I translate this into VB? 我如何将其翻译成VB? The obvious choice is:
显而易见的选择是:
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
But the complier is throwing an error (as shown above). 但编译器抛出错误(如上所示)。 It seems to think that error message is property of album.
好像认为错误信息是专辑的财产。
What can I do to fix this? 我该怎么做才能解决这个问题?
This should be: 这应该是:
<Required(ErrorMessage := "Price is required")> _
<StringLength(160)> _
Check out the VB documentation on attributes for more information. 有关更多信息,请查看有关属性的VB文档 。
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.