Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Wow. That was easy. I know the OP wanted to add custom string descriptions, but this is what I needed. I should have known to try this, in retrospect, but I went down the Enum.GetName route. Commented Sep 23, 2012 at 6:52
  • 18
    @Brent Because most often you have the .ToString() value different than the user-friendly value you need. Commented Apr 23, 2014 at 13:35
  • 2
    @Brent - because this is different than the question being asked. The question being ask is how to you get this string from a variable that has been assigned an enumerated value. That is dynamic at run time. This is checking the definition of the type and set at run time. Commented Jul 10, 2015 at 19:03
  • 1
    @Hogan - the ToString() works on variables as well: any fruit = any.Tomato; string tomato = fruit.ToString(); Commented Jul 14, 2017 at 14:49
  • @LiborV - please remember this was written in 09 -- C# was different then and ToString() on an instance of an enumeration did something different. Commented Jul 14, 2017 at 20:16