You should have an interface with the appropriate properties, for example, something like this:
internal interface ICreditTradeline { string CreditorName { get; set; } string CreditLiabilityID { get; set; } string BorrowerID { get; set; } }
In your method, you need to add a restriction on T , requiring it to implement the interface:
where T: ICreditTradeline, new()
Your two classes should implement the interface:
class CreditTradeline : ICreditTradeline { // etc... } class CreditSupplementTradeline : ICreditTradeline { // etc... }
Then you can call the method with the class as a parameter of your type:
CreditTradeline result = this.GetCreditTradeLine<CreditTradeline>(xElement, s);
source share