If I understand correctly, you want to compare the type itself, not the instances inside this list.
You can do it as follows:
List<string> metadata = new List<string>();
metadata.Add("itemname");
metadata.Add("soid");
metadata.Add("qty");
metadata.Add("yada");
var result = from str in metadata
join prop in typeof(Input).GetProperties() on str equals prop.Name
select str;
foreach (string prop in result)
{
Console.WriteLine(prop);
}
, T , , .
: when we get the common name between list<input> and string how will get the value of corresponding member of the class.now you return only common names r8..?
. , :
public class Input
{
public string soid { get; set; }
public string itemname { get; set; }
public int qty { get; set; }
}
public class Yada : Input
{
public string yada { get; set; }
}
So Input 3 4 , Yada 4.
, :
List<Input> inputclass = new List<Input>();
inputclass.Add(new Input() { itemname = "test",soid="myId",qty=10 });
inputclass.Add(new Yada() { itemname = "test2",soid="myId2", yada = "woo",qty=20 });
, , :
var result = inputclass.Select(
input => (from str in metadata
join prop in input.GetType().GetProperties()
on str equals prop.Name
select new { Obj = input, Prop = str, Value = prop.GetValue(input, null) }))
.SelectMany(i => i)
.GroupBy(obj => obj.Obj);
foreach (var obj in result)
{
Console.WriteLine(obj.Key);
foreach (var prop in obj)
{
Console.WriteLine(prop.Prop + ":" + prop.Value);
}
Console.WriteLine();
}
Console.ReadKey();
:

, GetValue: , , .