Why does Enum.GetValues() return names when using “var”?

前端 未结 7 1055
囚心锁ツ
囚心锁ツ 2021-01-17 07:44

Can anyone explain this?

alt text http://www.deviantsart.com/upload/g4knqc.png

using System;

namespace TestEnum2342394834
{
    class Program
    {
         


        
相关标签:
7条回答
  • 2021-01-17 08:11

    You implicitely call ToString() on each element when you use Console.WriteLine.

    And when you say you want an int (using the explicit type) it will convert it to an int - and then ToString() it.

    The first one is the Enum value ToString()'ed

    0 讨论(0)
提交回复
热议问题