CSharp - List enum underline value

Introduction

The following code uses Enum type GetValues() method to get the underline value for an enum type.

Demo

using System;

class Program/*from  w ww  .  ja  v a  2  s. c  o m*/
{
    enum Values { val1, val2 = 100, val3 = 50, val4, val5 };
    static void Main(string[] args)
    {
        foreach (Values v in Enum.GetValues(typeof(Values)))
        {
            Console.WriteLine("{0} is storing {1}", v, (int)v);
        }
    }
}

Result

Related Example