NullReferenceException in unexpected place with LINQ GroupBy

IvanKirkorau.3935IvanKirkorau.3935 CNUniversity ✭✭
edited May 2016 in Workbooks & Inspector

I have written some code to demonstrate LINQ, but GroupBy doesn't want to execute. I get strange exception:

NullReferenceException: Object reference not set to an instance of an object
at void Xamarin.Inspector.Repl.ReplViewModel.c__async7.MoveNext ()

    var input = new int[1000];
    var rnd = new Random();     
    for (int i = 0; i < input.Length; i++)
    {
        input[i] = rnd.Next(100);
    }
    var q = from p in input 
        group p by p into g
        select new {Key = g.Key, Freq = g.Count()};

or

var q = input.GroupBy(x => x, (p, g) => new { Key = p, Freq = g.Count() }).ToList();

Each piece of code can not run in Workbook, but I can run it successfully elsewhere.

Answers

  • prashantvcprashantvc USXamarin Team Xamurai

    I know you posted this last year, did you give it a try in the new version of Workbooks (v1.1.2.0)? It doesn't happen anymore
    Let us know if you still see this issue

Sign In or Register to comment.