c# - Adding a string to a List<string> inside of a List<List<string>> -


im trying add string object list inside of list> in & while loop, trying use var list object wish use.

here code of class, on im doing wrong appreciated :)

public class genclass {      private static int _gencount;     private static bool _filesloadedtolists;     private static list<string> _nounsetone = new list<string>();     private static list<string> _nounsettwo = new list<string>();     private static list<list<string>> _toload = new list<list<string>>();      private string _emotionmidtrim = "";      public const string fileone = "nounsetone.txt";     public const string filetwo = "nounsettwo.txt";      public genclass()     {         while (_filesloadedtolists == false)         {             texttolist(fileone,filetwo);             _filesloadedtolists = true;         }          _gencount++;     } 

the problem withing part of class

    public void texttolist(string fileone, string filetwo)     {         list<string> filestoread = new list<string>();          filestoread.add(fileone); // add text files read list         filestoread.add(filetwo); // add text files read list          _toload.add(_nounsetone); // add list of words list         _toload.add(_nounsettwo); // add list of words list          (int = 0; <= filestoread.count; i++)         {              using (var reader = new streamreader(filestoread[i]))              {                  string line;                  while ((line = reader.readline()) != null)                  {                      _toload[i.add(line)]; // error here                  }              }         } 

try using file.readalllines(). replace loop with:

foreach(var file in filestoread) {   _toload.add(file.readalllines(file).tolist()); } 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -