This is my code:
void Main()
{
StarTrek baseClass = new StarTrek();
NewGeneration childClass = new NewGeneration();
baseClass.ShowEnum();
childClass.ShowEnum();
}
public class StarTrek
{
internal enum Characters
{
Kirk, Spock, Sulu, Scott
}
public void ShowEnum()
{
Type reflectedEnum = typeof(Characters);
IEnumerable<string> members = reflectedEnum.GetFields()
.ToList()
.Where(item => item.IsSpecialName == false)
.Select(item => item.Name);
string.Join(", ", members).Dump();
}
}
public class NewGeneration : StarTrek
{
internal new enum Characters
{
Picard, Riker, Worf, Geordi
}
}
ShowEnum always displays:
Kirk, Spock, Sulu, Scott
even if it was called in the NewGeneration class. Am I missing/misunderstanding something? Is there a way for ShowEnum to use the NewGeneration.Characters instead of StarTrek.Characters?