I am writing a WCF service and I want to use DataTransferObjects that basically clone all fields of my classes.
For example I have a class Person
class Person
{
public int Id;
public string Name;
public Person()
{
//Some complex stuff here
}
}
class PersonDTO
{
//Copy all public fields and properties of Person
public int Id;
public string Name;
}
Is there a way to generate my DTO class based on other class? A code-snippet or something like that?
I am not trying to copy the values of the fields. I want to generate a class with same fields as the "Parent" class. But I don't want to inherit my DTO class