In My VB.NET Code, it is apparent that VB.NET will allow an object that is essentially a List to be looped through while C# does not. Below is the VB.NET code:
The C# conversion is below, and Intellisense seems to have accepted it without errors (I have not run it yet).Code:Dim dicData As New SortedDictionary(Of Integer, List(Of Object)) For Each kvp As KeyValuePair(Of Integer, List(Of Object)) In dicData Dim mylist As New List(Of Object) mylist = kvp.Value For Each items In mylist Dim x As Double = items(j - 2) 'Here, VB.NET "knows" each items is a List Dim y As Double = items(items.count - 2) Dim z As Double = items(items.count - 1) '.... Next Next
Code:foreach (KeyValuePair<int, List<object>> kvp in dicData) { List<object> mylist = new List<object>(); mylist = kvp.Value.Cast<object>().ToList(); foreach (var items in mylist) { var mylist2 = items as IList; //Will this do the trick? double x = Convert.ToDouble(mylist2[j - 2]); double y = Convert.ToDouble(mylist2[mylist2.Count - 2]); double z = Convert.ToDouble(mylist2[mylist2.Count - 1]); //.... } }




Reply With Quote
