Error in Cannot convert lambda expression to type 'string' because it is not a delegate type

Posted by Rakeshtripathy111 under C# on 6/25/2013 | Points: 10 | Views : 1877 | Status : [Member] | Replies : 1
Hi....

Below is the table structure with data

DataTable Emp = new DataTable();
Emp.Columns.Add("Id", System.Type.GetType("System.Int32"));
Emp.Columns.Add("Name", System.Type.GetType("System.String"));
Emp.Columns.Add("Deptid", System.Type.GetType("System.Int32"));
Emp.Rows.Add(1, "Vasanth",1);
Emp.Rows.Add(2, "Pradeep",2);
Emp.Rows.Add(3, "Rakesh",3);


Using Lambda expression i need to select Id and name column from the data table. Its not working. Let me know if you find the answer

var result3 = Emp.Select( E => new { empid = E.Id, empname = E.Name });

But it was displaying error.

Error : Cannot convert lambda expression to type 'string' because it is not a delegate type

Please gime me the solution




Responses

Posted by: aswinialuri-19361 on: 6/25/2013 [Member] Starter | Points: 25

Up
0
Down
hi,
refer this link it might help ful to you
http://forums.asp.net/t/1739723.aspx/1

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Rakeshtripathy111, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response