2017-09-18 1 views
1

에 C#을에서 변환 한 후 나는이 변환 된 VB.NET 코드 http://converter.telerik.com/오류 VB.NET

public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image) 
{ 
    _messageBox = new WpfMessageBox { Label1 = { Content = caption }, Label2 = { Content = text } }; 
    return _result; 
} 

를 통해 VB.NET 코드에 다음과 같은 C# 코드를 변환했다. 이 컨버터의 버그

Error

+0

vb.net에서이 구문이 잘못되었습니다. 인라인 초기화를 사용하여 WpfMessageBox를 초기화하는 방법에 대해 읽어야합니다. 또는 먼저 WpfMessageBox의 인스턴스를 만들고 해당 속성을 설정합니다. –

답변

1

변환기는 익명 형식이 여기에 관련되어 있다고 생각하는 것처럼 보이지만 그렇지 않습니다. Key을 삭제하십시오.

Public Shared Function Show(caption As String, text As String, button As MessageBoxButton, image As MessageBoxImage) As MessageBoxResult 
    _messageBox = New WpfMessageBox() 
    _messageBox.Label1.Content = caption 
    _messageBox.Label2.Content = text 
    Return _result 
End Function 
+0

@MarkoMarkowitz :'System.Windows.Controls'가 들여 오면'New Label()'을 추가하도록 업데이트되었습니다. – Ryan

+0

@MarkoMarkowitz : 죄송합니다. 키워드를 잊어 버렸습니다. 'WpfMessageBox'를 만들 때와 마찬가지로'New Label() With'입니다. – Ryan

2

: 여기

Public Shared Function Show(caption As String, text As String, button As MessageBoxButton, image As MessageBoxImage) As MessageBoxResult 
    _messageBox = New WpfMessageBox() With { _ 
     Key .Label1 = {Key .Content = caption}, _ 
     Key .Label2 = {Key .Content = text} _ 
    } 
    Return _result 
End Function 

는 오류입니다.

Key prefix은 익명 형식이 같음에 영향을주는 데 사용됩니다. 타입이 지정된 객체 이니셜 라이저에는 적합하지 않습니다.

제거하십시오.