System.Linq.Enumerable+WhereSelectListIterator`2 error -


i getting error : system.linq.enumerable+whereselectlistiterator2[consoleapplication1.person,<>f_ _anonymoustype02[system.string,system.string]]

when try in console application :

public class person {     public int id;     public int idrole;     public string firstname;     public string lastname; }    class program     {         static void main(string[] args)         { list<person> people = new list<person> {         new person() {id = 1, idrole = 1, lastname= "anderson",         firstname = "brad"},         new person() {id = 2, idrole = 2, lastname= "gray",         firstname = "tom"}         };          var query = p in people                     p.id == 1                     select new { p.firstname, p.lastname };        console.write( query);        console.readline();  }} 

you need iterate query

foreach(var q in query)     {       console.write( string.format("{0} {1}",new []{ q.firstname ,q.lastname }));     }     console.readline(); 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -