LINQPad strange bug

The following code causes an Object reference not set to an instance of an object in LINQPad, but works in VS 2017:

var anObjectList = new List { "name", new[,] { { 1 } } };

Console.Write("Length ");
Console.WriteLine(anObjectList.Count());
Console.WriteLine(anObjectList[1]);

Comments

  • This code doesn't compile for me (in either linqpad or VS). I get "CS0305 Using the generic type 'List' requires 1 type arguments"
  • It looks like you're trying to create a list of anonymous type. I don't think that works. Try this instead.

    var anObjectList = new[] { o, o1 }.ToList();
  • Sorry, the post got mangled by the comment editor - trying again for the first line:

    var anObjectList = new List<object> { "name", new[,] { { 1 } } };

  • Works fine for me. What version of LINQPad are you using?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!