How to debug LINQ code

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
say this is my sample code

string[,] rows = new string[,]{
{"1","2","5","10"},
{"9","6","20","11"},
{"7","4","9","30"},
{"4","13","80","40"},
{"9","12","55","50"},
{"6","19","21","60"},
//{"=SUM(A1:A2)","=SUM(B1:B6)","=SUM(C1:C3)","=SUM(D2:D5)"}
};


string[] sum = rows.Cast<string>().Select((x, i) => new { value = x, column = i % 4 })
.GroupBy(x => x.column)
.Select(x => x.Sum(y => int.Parse(y.value))
.ToString()).ToArray();

when the below code will execute then how could i debug the value ? i believe when below code will execute then a internally loop will run by .net. so how could i debug to see what value is coming and storing in variable x & i for each iteration ?

string[] sum = rows.Cast<string>().Select((x, i) => new { value = x, column = i % 4 })
.GroupBy(x => x.column)
.Select(x => x.Sum(y => int.Parse(y.value))
.ToString()).ToArray();

Continue reading...
 
Back
Top