Consider the following code.
public string[][] CalculateDistance(string origin, string destination)
{
string[][] result = new string[1][];
string url = "MyUrl"
string requesturl = url;
string content = fileGetContents(requesturl);
JObject o = JObject.Parse(content);
result[0] = new string[2];
result[0][0] = (string)o.SelectToken("routes[0].legs[0].distance.text");
result[0][1] = (string)o.SelectToken("routes[0].legs[0].duration.text");
string[][] myArray = new string[2][];
for (int i = 0; i < result.Length; i++)
{
string[] innerArray = result[i];
}
return result;
}
I'm trying to return a jagged array which I then use on a ListView in a wpf application. If I use Console.WriteLine(innerArray)
inside the for
loop I get the correct result displayed. However when displayed in the ListView
I get
String[][] Array
Can someone please tell me where I'm going wrong. I've never worked with jagged arrays before so I'm finding it really difficult to figure out what I'm doing wrong.
XMAL Code looks like:
<ListView Name="MyList" HorizontalAlignment="Left" Height="315" Margin="1289,425,-435,0" VerticalAlignment="Top" Width="421">
<ListView.View>
<GridView>
<GridViewColumn Header="Name"
DisplayMemberBinding="{Binding Time}"
Width="100"/>
</GridView>
</ListView.View>
</ListView>
And the backend to add items to the list I use:
foreach (var items in GetAddress())
{
MyList.Items.Add(new Distance() { Time = distance.CalculateDistance(items.FromPostCode, items.DestinationPostCode) });
}
Distance Class looks like
public class Distance
{
public string[][] Time { get; set; }
//More properties
}