从 C# 转换为 VB.NET 后键 属性 出错

Error on Key property after converting from C# to VB.NET

我已通过 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

这是错误:

这是转换器中的错误。

Key prefix用于匿名类型影响相等;类型化对象初始值设定项是非法的。

删除那个。

转换器似乎认为这里涉及匿名类型,但实际上没有。删除 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