mukesh kv

mukesh kv

  • NA
  • 16
  • 0

Copy list object into object of another list object

Aug 1 2011 3:49 AM
Hi all,
I have two list objects, say List<UPDTO>   and List<PDTO>
 
class PDTO
{
public string Prop1{get; set;}
}
 
class UPDTO
{
public PDTO oPDTO {get; set;}
}
 

I have data in   List<PDTO>. And I want this to get copied to the object (PDTO) that I have in List<UPDTO>. Could you please let me know the solution?
 
We can do the same like the below:
 
foreach (PDTO oPDTO1 in oListPDTO)
{
      oListUPDTO.Add(new UPDTO() { oPDTO = oPDTO1 });
}
Is there any better way of doing this?
 

Thanks,
Mukesh KV

Answers (5)