Get int value from enum in C#

前端 未结 28 2510
臣服心动
臣服心动 2020-11-22 04:58

I have a class called Questions (plural). In this class there is an enum called Question (singular) which looks like this.

public e         


        
28条回答
  •  感动是毒
    2020-11-22 05:31

    One more way to do it:

    Console.WriteLine("Name: {0}, Value: {0:D}", Question.Role);
    

    It will result in:

    Name: Role, Value: 2
    

提交回复
热议问题