this
works in all cases I can think of. For example, you can access the list directly by index, or use the base class methods:
public class MyList : List<string>
{
public string GetAt(int index)
{
return this[index];
}
public void AddMe(string s)
{
Add(s);
}
}
What are you trying to do that doesn't work?
"One of the things I would like to do is illustrated in my first description: Do some processing of constructor parameters to initialize the list member.
Another thing (not illustrated in my code) is to extract the list element itself, without the augmentations (in the form of extra parameters), like an AugmentedStringList.GetSimpleList() function, similar to AugmentedStringList.GetLanguage(). How do I write GetSimpleList() - how can I refer to the base class list?"
You can't call a base constructor from within the inherited class constructor - the base construction has to be complete before the inherited constructor code is executed, or it could try to use uninitialized memory. So what you are trying to do can't be done. But, you could create two constructors in the inherited class (one with a single param, and one with two) that reference the base constructors appropriately:
public string Lang { get; set; }
public MyList(string lang)
{
Lang = lang;
}
public MyList(string lang, string initialStrings)
: base(initialStrings.Split(';'))
{
Lang = lang;
}
To return the base class is easy: your class instance is an instance of the base class:
public List<string> GetSimpleList()
{
return this;
}
But to be honest you don't need to do that, because:
MyList ml = new MyList("English", "hello;hello again");
List<string> ls = ml;
Will work fine anyway!