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 void LoadFromFile(string FileName)
{
//does not work because _list is private
this._items = File.ReadAllLines(FileName).ToList();
}
}
But I dont know how to load the lines into the _items property because it is private.
Any suggestions?
ListExtis the list – so you can just callAddRangeon yourself. You can’t reassign the list – that would essentially be changingthis.