C# - Accesing to items for a collection inherited from List<string>

Posted by Salvador on Stack Overflow See other posts from Stack Overflow or by Salvador
Published on 2010-04-15T15:51:19Z Indexed on 2010/04/15 15:53 UTC
Read the original article Hit count: 383

Filed under:
|
|

I am trying to implement a new class inherited from List<string>, to load the contents from a text file to the items.

using System.Collections.Generic;
using System.IO;
using System.Linq;


public class ListExt: List<string>
{
    string baseDirectory;

    public LoadFromFile(string FileName)
    {
        this._items = File.ReadAllLines(FileName).ToList();//does not work because _list is private
    }

}

but i dont knew how to load the lines into the _items property because is private.

any suggestions?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET