c# - Loop generates alot of lines? -


I generate many null-lines due to this code, so I can not wrap my head:

  int nr = 0; Foreach (Select different items in the list (X => x.match_id)) {foreach (var match in the list) {Console.Write (match .name where. (X = & gt; lists [nr] .match_id = = Match .match_id). Select (z = & gt; mail.name). First and Default ()); } NR ++; }  

list is an array of objects:

All tapes have the next record, and then more null etc. Why?

zero to not output, call you on the console Should not. If the value is null .

Try something like this:

  int nr = 0; Foreach (list var item in list (x = & gt; x.match_id)) {foreach (var match in list) {var n = match.nickname. Select (x = & gt; lists [nr] .match_id == match match_id) Select (z = & gt; mail.name). Before and after default (); If (n = = null) {console. Write (n); }} NR ++; }  

Comments