Q
Q
Quip Quip2016-03-04 15:57:11
Programming
Quip Quip, 2016-03-04 15:57:11

How to fill an array with an enum value?

There is an enum list that contains some values, how to push these values ​​\u200b\u200binto an array, so that when the array index is entered, the value from the enum is displayed on the screen.
namespace HomeWork5._2
{
class Program
{
static void Main(string[] args)
{
string[] orders = new string[20] { "1", "0", "2", "4", "3", " 2", "3", "0", "0", "0", "1", "2", "3", "4", "1", "2", "3", "0" , "4", "1" };
Console.WriteLine("Enter order number:");
string orderNumberString = Console.ReadLine();
Array.IndexOf(orders, orderNumberString);
var orderNumber = orders[int.Parse(orderNumberString)];
Console.WriteLine("Your order status: {0}", Enum.GetName(typeof(stateOrder), int.Parse(orderNumber)));
Console.ReadKey();
}
enum stateOrder
{
Sent, // Sent
Uncollected, // Not collected
Reated, // Processed by the Paid
system, //
AwaitingPayment paid // Awaiting payment
}
}
}
the string was a value, and the value was from an enum list.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
V Sh., 2016-03-04
@QuipQuip

stateOrder[] arrayOfStates = new stateOrder[1] {stateOrder.Sent};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question