.net - c# columns names from ilist -


this may simple. have created class list

public class lstlog {     public string column1;     public string column2;     public string column3;     public string column4;     // methods     public lstlog(string column1, string column2, string column3, string column4)     {         this.column1 = column1;         this.column2 = column2;         this.column3 = column3;         this.column4 = column4;      } 

i can insert , read contents of list @ runtime. column names @ runtime. possible? thanks.

you should use dictionary can query columns name , add/insert new ones needed.

public class lstlog {     private dictionary<string, string> columndictionary = new dictionary<string, string>();      // methods     public lstlog(string column1, string column2, string column3, string column4)     {         columndictionary["column1"] = column1;         columndictionary["column2"] = column1;         columndictionary["column3"] = column1;         columndictionary["column4"] = column1;     }     public string getcolumnvalue(string columnname)     {         if(columndictionary.containskey(columnname)             return columndictionary[columnname];         else              return null;     } } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -