0

I write enum with custom ToString() method example

  public enum MyEnum{
        a,
        b,
  }
  My = MyEnum.a;
  Console.Write(My.ToString); // ---> output : aaaaa

and in code My.ToString() Do you have idea ?

Arian Jira
  • 11
  • 4
  • You can't directly do it in C#, but there's plenty of workaround to choose https://stackoverflow.com/questions/479410/enum-tostring-with-user-friendly-strings – Martheen May 16 '20 at 06:08

1 Answers1

1

Another simple technich if you dont need complex string, is to have 2 enum collection

public enum MyEnum1{
    a,
    b,
}

public enum MyEnum2{
    aaaaa,
    bbbbb,
}

var My = MyEnum.a;
Console.Write((MyEnum2)My).ToString()) // ---> output : aaaaa
Frenchy
  • 16,386
  • 3
  • 16
  • 39