我已通过http://converter.telerik.com/
将以下C#代码转换为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代码。
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
这是错误:
答案 0 :(得分:2)
答案 1 :(得分: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