I have a piece of C# code where I have created an anonymous type object as follows:
var measurementUnits = new List<dynamic>() {
new { Unit = "SQF", Display = new List<string>() { "F", "FT", "SQ FT" }, Ratio=1.5 } ,
new { Unit = "Hectares", Display = new List<string>() { "H", "HEC"} , Ratio=2.5},
new { Unit = "Acres", Display = new List<string>() { "AC(TO)" } , Ratio=3.5},
new { Unit = "SQM", Display = new List<string>() { "M", "SQ M"}, Ratio=4.5 }
};
Through LINQ I want to access the Ratio where Display="HEC" (case-insensitive) something like:
var multiplier = measurementUnits.Where(m => m.Display == "HEC").First().Ratio;
dynamichere at all? I don't see anything dynamic in what you're doing... why not just create a list of the anonymous type, and keep all the benefits of static typing?