I want to load a properties file (it\'s a .csv file having on each line a name and associated numeric value) and then access those property values like so: FileLoader
Here's a sample using ExpandoObject and C#`s 4.0 dynamic feature
public dynamic ParseCsvFile(string filePath) {
var expando = new ExpandoObject;
IDictionary map = expando;
foreach ( var line in File.ReadAllLines(filePath)) {
var array = line.Split(new char[]{','},2);
map.Add(array[0],array[1]);
}
return expando;
}
...
var d = ParseCsvFile(someFilePath);
Console.WriteLine(d.Property1);