Create Shapes Enum
public enum Shapes
{
Circle,
Square,
Rectangle,
TryAngle
}
Create
integer array then call to Shapes Enum
//Get Shapes value
Console.WriteLine("Values from Shapes Enum");
foreach (int values in shapeValues)
{
Console.WriteLine(values);
}
Create string array then call to Shapes Enum
//Get Shapes names
Console.WriteLine("Names from Shapes Enum");
string[] shapeNames = (string[])Enum.GetNames(typeof(Shapes));
foreach (string Names in shapeNames)
{
Console.WriteLine(Names);
}
Print
both Shapes and values
//Get Shape names & Values
Console.WriteLine("Names & values from ShapesValue Enum");
foreach (ShapesValue shapes in Enum.GetValues(typeof(ShapesValue)))
{
Console.WriteLine("{0} - {1}",
shapes, (int)shapes);
}
No comments:
Post a Comment