I have two classes:
public class MyClass1
{
public string AAAAA { get; set; }
public string BBBBB { get; set; }
public string CCCCC { get; set; }
public string DDDDD { get; set; }
}
public class MyClass2
{
public string AAAAA { get; set; } // same as MyClass1
public string BBBBB { get; set; } // same as MyClass1
public string TTTTT { get; set; }
}
Now I want to create this method:
public string PrintMe( Class1or2 obj) {
string message = "";
message += obj.AAAAA ; // this parameter is in both MyClass1 and MyClass2
message += obj.BBBBB ; // this parameter is in both MyClass1 and MyClass2
return message;
}
The point is – that I can't touch MyClass1 and MyClass2 so I can't make them use the same base. They are totally separated.
Is any way to create this method somehow or I'll have do duplicate it for each class?