Possible Duplicate:
Get property value from string using reflection in C#
I am trying to write a generic method to allow me to specific a property to retrieve when iterating through a collection:
private void WriteStatisticsRow<T>(ICollection<InstitutionStatistics> stats,
ICollection<short> years,
string statisticsName,
string rangeName) where T : struct
{
Console.WriteLine(statisticsName);
foreach (short yr in years)
{
var stat = stats.SingleOrDefault(s => s.InformationYear == yr);
if (stat != null)
{
if (typeof(T) == typeof(double))
{
Console.WriteLine(value, format: "0.0");
}
else
{
Console.WriteLine(value);
}
}
else
{
Console.WriteLin(string.Empty);
}
}
}
Basically, I want to iterate through the stats collection, and write out a specified property's value. I assume that I can use LINQ expressions to do this, but I have no idea how!