I need to declare a List of Enums and I can't figure out how to do it right.
This is my code so far:
public enum Languages
{
Ger,Eng,Fra,Ita,Rus
}
public class Player
{
public string ID { get; private set; }
private List<Languages> Languages;
public Player(string ID, List<Languages> LangList)
{
this.ID = ID;
this.Languages = LangList;
}
}
class Program
{
static void Main(string[] args)
{
Player PlayerA = new Player("Player A", **[Problem is here]**);
}
}
As you can see the constructor of Player expects a list of languages that are supported by the player. I wanted to define the possible Languages as enums. Now i don't know how i declare such a list in the construction call.
I know i could just do it like this:
List<FoolMeLib.Languages> pLang = new List<FoolMeLib.Languages>;
pLang.Add(FoolMeLib.Languages.Ger);
pLang.Add(FoolMeLib.Languages.Eng);
NewGame.AddPlayer(new FoolMeLib.Player("Player A", pLang));
but i want to write the code as sleek as possible... Btw: if you see any other bad practice: tell me. I'm triing to improve.