gpt4 book ai didi

c# - 如何将这行代码从 C# 转换为 Visual Basic

转载 作者:太空狗 更新时间:2023-10-29 23:00:10 24 4
gpt4 key购买 nike

我需要一些关于翻译这段代码的帮助:

C# 原文:

using System.Collections.ObjectModel;
using Microsoft.Maps.MapControl;

namespace Binding_Bing_Map_Control.Modal
{
public class MapModal
{
public Location MapLocation { get; set; }
public string TooltipText { get; set; }

public static ObservableCollection<MapModal> getMapRecords()
{
ObservableCollection<MapModal> MapRecords = new ObservableCollection<MapModal>();
MapRecords.Add(new MapModal() { MapLocation = new Location(47.610015, -122.188362), TooltipText = "Main St, Bellevue, WA 98004" });
MapRecords.Add(new MapModal() { MapLocation = new Location(47.603562, -122.329496), TooltipText = "James St, Seattle, wa 98104" });
MapRecords.Add(new MapModal() { MapLocation = new Location(47.609355, -122.189970), TooltipText = "Main St, Bellevue, WA 98004-6405" });
MapRecords.Add(new MapModal() { MapLocation = new Location(47.615820, -122.238973), TooltipText = "601 76th Ave, Medina ,WA 98039" });
return MapRecords;
}
}
}

我对 VB 的翻译:

Imports System.Collections.ObjectModel
Imports Microsoft.Maps.MapControl

Namespace Map_Control.Modal

Public Class MapModal

Public Property Location As WPF.Location
Public Property TooltipTex As String

Public Function getMapRecors() As ObservableCollection(Of MapModal)
Dim MapRecords As New ObservableCollection(Of MapModal)
MapRecords.Add(New MapModal() {Location = New WPF.Location(47, -122), TooltipTex = "Sample tooltiptext!"})
Return MapRecords
End Function

End Class

End Namespace

我在行中遇到错误:

MapRecords.Add(New MapModal() {Location = New WPF.Location(47, -122), TooltipTex = "Sample tooltiptext!"})

错误: bool 类型的值无法转换为 WindowsApplication1.Map_Control.Modal.MapModal

澄清我在做什么。我正在尝试构建 wpf 应用程序并使用 bing map 。我正在关注此 link. 中的代码,但我没有使用 Silverlight,而是在 VB 中编码。

最佳答案

尝试这样的事情:

MapRecords.Add(New MapModal() With {.Location = New WPF.Location(47, -122), .TooltipTex = "Sample tooltiptext!"})

关于c# - 如何将这行代码从 C# 转换为 Visual Basic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16943554/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com