0

I'm doing a little project for school and I'm stuck on the fact that they want us to use collectionbase and file handling...

My question is what do I need to do on launch of the app to open the .txt file and populate a collectionbase? Is this possible? Or is there another way to make the app remember the collectionbase?

My code so far:

    System.IO.StreamReader reader = new System.IO.StreamReader("Auth.txt");
    String text = reader.ReadToEnd();
    StringBuilder sb = new StringBuilder(); 
    if (File.ReadAllText("Comptes.txt").Contains(Nm))    
    {
        String[] strLines = File.ReadAllLines("Comptes.txt");
        foreach (String strLine in strLines)
            sb.AppendLine(strLine);   
        label1Welcome.Text = sb.ToString();    
        ////here is where I'm stuck - how to insert info in collectionbase 
    }  
    else
    {
       label1Welcome.Text = "!!";
    }
}
John Saunders
  • 160,644
  • 26
  • 247
  • 397
techker
  • 189
  • 1
  • 10
  • 1
    Where is your CollectionBase class? – Rufus L Jan 14 '15 at 00:39
  • See [CollectionBase](http://msdn.microsoft.com/en-us/library/system.collections.collectionbase%28v=vs.110%29.aspx): "Provides the **abstract base class** for a strongly typed collection." Now go look at [Abstract Classes](http://msdn.microsoft.com/en-us/library/k535acbf%28v=vs.71%29.aspx): "A class that is derived from an abstract class ..." So a good start would be to make a new `class` that **derives** from `CollectionBase` by **inheriting** from it. Check out [Inheritance](http://msdn.microsoft.com/en-us/library/vstudio/ms173149(v=vs.100).aspx). Good luck! – Idle_Mind Jan 14 '15 at 00:48

0 Answers0