I have a problem with my code but I'm not sure where. I'm attempting to return an enum value from an enum collection/class. However when I try do this, instead of returning the value, it returns a number of the actual enum value.
E.G
thisisamaptype = 5;
would return "5" instead of the Enum name its self.
Is there a way to get the Enum value from the associated number provided by the method?
Random rnd = new Random();
public static MapTypes GetMapType(string Type)
{
switch (Type.ToLower())
{
default:
case "default":
return (MapTypes)(rnd.Next(1,Enum.GetNames(typeof(MapTypes)).Length));
}
}
Aucun commentaire:
Enregistrer un commentaire