For some reason, i need to copy only view details from one list into another list.
public class c1
{
public string id{get;set;}
public string firstname{get;set;}
public string lastname{get;set;}
public string category{get;set;}
public string gender{get;set;}
}
public class c2
{
public string id{get;set;}
public string firstname{get;set;}
}
Here, in runtime, I will get all the details for the c1 class, and I need to store only 2parameters to store into c2. How can i achieve this? I tried below, but its not working!!
dynamic d=from a in c1
select new
{
a.id,
a.firstname
};
List<c2> c2list=d;
CodePudding user response: