public static void CreateCsv <T>(string path, string name, IEnumerable <T> objects, LogController ui) { name = GetCsvFileName(name); if (objects != null && objects.Any(o => o != null)) { var typeToOutput = objects.First(o => o != null).GetType(); var propertyNames = typeToOutput.GetReadableProperties().Select(s => s.Name).ToArray(); CreateCsv(path, name, objects, propertyNames , delegate(string s) { return(typeToOutput.GetProperty(s).GetDisplayName()); }, delegate(object o, string s) { return(o.GetPropertyValue(s)); }); } }