2013-06-05 19 views
5
ben bu kodu tercüme tek satıra biraz yardıma ihtiyacım

için C# kod bu çizgiyi nasıl çevrilir?: VBGörsel baisc

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; 
    } 
} 
} 

Benim çeviri:

Orjinal

C#

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 

Ben doğrultusunda hatayı alıyorum:

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

Hata: Boole türü, WindowsApplication1.Map_Control.Modal.MapModal

'a dönüştürülemiyor. Ne yaptığımı açıklığa kavuşturmak için. Wpf uygulamasını oluşturmaya ve bing haritaları kullanmaya çalışıyorum. Bu link. kodunu izliyorum, ancak Silverlight kullanmıyorum ve VB'de kod yapıyorum.

+1

+1, iyi belgelenmiş ve basitçe "benim için kodumu dönüştür" demez. –

+0

+1 - @Evanlewis ile aynı - Plus, diğer tercüme soruları – Sayse

+0

ile ilişkilendirmek için bir soru olarak yararlıdır. Herkesin bir başkasının "tüm bu kodu benim için değiştir" sorusunu beklediğini düşünüyorum. – SysDragon

cevap

5

böyle bir şey deneyin: özgü bir çeviri sorusu için

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

Teşekkürler Medinoc, bunu çözdü. – micco

1

Buradaki sorunun olduğunu düşünüyorum:

public Location MapLocation { get; set; } 

Bu hat

Public Property Location As WPF.Location 

Sana Yer sınıfının bulaştığın düşünmek tercüme edilemez. C# sürümünde WPF ad alanı için böyle bir başvuru olmadığına dikkat edin.

+0

Farklı Referanslar kullanıyorum. Orijinalde 'wpf maps api' kullandığım 'silverlight map api' referans noktaları. – micco

1

sözdizimi initialiazer nesne VB.Net'te farklı - Ben an online translator kullanılmış ve bu var:

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

Namespace Binding_Bing_Map_Control.Modal 
    Public Class MapModal 

     Public Property Location As Location 
     Public Property TooltipTex As String 

     Public Shared Function getMapRecords() As ObservableCollection(Of MapModal) 
      Dim MapRecords As New ObservableCollection(Of MapModal)() 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.610015, -122.188362), _ 
       Key .TooltipText = "Main St, Bellevue, WA 98004" _ 
      }) 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.603562, -122.329496), _ 
       Key .TooltipText = "James St, Seattle, wa 98104" _ 
      }) 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.609355, -122.18997), _ 
       Key .TooltipText = "Main St, Bellevue, WA 98004-6405" _ 
      }) 
      MapRecords.Add(New MapModal() With { _ 
       Key .MapLocation = New Location(47.61582, -122.238973), _ 
       Key .TooltipText = "601 76th Ave, Medina ,WA 98039" _ 
      }) 
      Return MapRecords 
     End Function 
    End Class 
End Namespace