c# - List Generic IEnumerable has some invalid arguments -



c# - List Generic IEnumerable has some invalid arguments -

i'm trying improve programme builds generic list of strings follows:

list<string> filelist = new list<string>(directory.getfiles(root, "*.xml", searchoption.alldirectories));

to different generic list more flexible:

list<inputfileinfo> filelist = list<inputfileinfo>(directory.getfiles(root, "*.xml", searchoption.alldirectories)); public class inputfileinfo { public string _fullpath { get; set; } public string _message { get; set; } public int _rowcount { get; set; } public inputfileinfo(string fname) { _fullpath = fname; _rowcount = 0; _message = string.empty; } }

directory.getfiles returns string array , guess inputfileinfo constructor not sufficient. need loop thru string array , populate list using .add method each element of .getfiles array or there way populate new list in 1 statement list of strings?

yes - ideally linq objects:

var filelist = directory.getfiles(root, "*.xml", searchoption.alldirectories); .select(name => new inputfileinfo(name)) .tolist();

if haven't come across linq yet, strongly recommend @ in detail. it's ideal sort of thing.

c# list generics

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -