When I type .ToString()
on an Enum
type in Visual Studio, the Intellisense shows a "strike-through" line through ToString()
(although it builds and works fine). It seems to indicate that Enum.ToString()
is deprecated in some way. Is this true? If so, why?
ToString() Converts the value of this instance to its equivalent string representation.
C# Enum ToString() Method The ToString() method converts the value of this instance to its equivalent string representation. Firstly, set an enum. enum Vehicle { Car, Bus, Truck, Motobike }; To convert it to an equivalent string representation, use ToString().
We can convert an enum to string by calling the ToString() method of an Enum.
The Enum.ToString overloads that take an IFormatProvider, ToString(IFormatProvider) and ToString(String, IFormatProvider), are both obsolete, because the IFormatProvider isn't used anyway.
The other overloads, ToString() and ToString(String), are not obsolete.
It's a feature of ReSharper to strike out obsolete class members. It's apparently not very good at it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With