I have these two classes
public class BuyEstimateResult
{
public string SubTitle { get; set; }
public string Value { get; set; }
public string Formulae { get; set; }
}
public class SellerReportClass
{
public string Entityname { get; set; }
public double EntityAmt { get; set; }
public string Formulae { get; set; }
}
I have to make them such that it should be converted as
public class KeyValue
{
public string key {get;set;}
public string value {get;set;}
}
if I pass BuyEstimateResult, its SubTitle should be key and Value should be Value of KeyValue Class and if I pass SellerReportClass then Entityname sould be key and EntityAmt should be Value
any ideas how can it be done
NOTE: I will get List of Both the class
You can use the
implicitoperator in C# to convert it into aKeyValuelike you want – http://msdn.microsoft.com/en-us/library/z5z9kes2(v=vs.110).aspxEdit
To be more specific on how to implement this:
To get a single list of
KeyValueobjects from the two different lists you can do something like this: