I am facing a problem in writing generic deep copy method which copies class 1 to class 2 of same structure with different namespace. After searching in net I was able to do at one level of mapping, but problem was if the properties are referring to some other user defined class how to do recursive deep copy. Below is the sample class for better clarity: From the below example I am trying to copy Namespace1.class1 to Namespace2.Class1 (Class1, GenderType, Subject exists both in NameSpace1 and NameSpace2).
Namespace1.Student
{
String Name {get;set;}
Int Age {get;set;}
List<Subject> lstSubjects {get;set;} //Here we need recursive copy.
GenderType gender {get;set;}
}
Enum GenderType
{
Male,
Female
}
NameSpace1.Subject
{
string subjectName {get;set;}
string lecturereName {get;set;}
}