2012-08-10 6 views
2

저는 MVC 3 noobie가 음악 상점 자습서를 통해 작동하지만 VB로 모든 것을 번역합니다 (VB 상점에서 일합니다).이 C# 속성을 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 

그러나 컴플라이언스는 오류를 발생시킵니다 (위 그림 참조). 오류 메시지가 앨범의 속성이라고 생각하는 것 같습니다.

이 문제를 해결하려면 어떻게해야합니까?

+0

VB.Net에는 * 지시어를 사용하는 C# *과 같은 것이 있습니까? 그렇다면이 코드에 대해 누락 되었습니까? –

+0

akh2103 완전히 변환 된 방법은 다음과 같습니다. 덕분에 – MethodMan

답변

0
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 
관련 문제