views:

114

answers:

1

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?

alt text

+9  A: 

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.

dtb
Specifically, the no-arg overload (`ToString()`) that the OP is using is **not** deprecated.
Michael Petrotta
Well, Intellisense strikes out "ToString" even before I expand the overloads
JoelFan
@Joel: what do you mean by "strikes out"? Do you get a compiler error or warning? What do you see when you mouse over that code?
Michael Petrotta
These guys have a similar experience: http://channel9.msdn.com/forums/Coffeehouse/250182-deprecated-string-EnumToStringIFormatProvider-provider/
Richard Cook
@Michael: I think the IntelliSense list shows the method name with a strikethrough font style. That's what I often see it do for deprecated methods.
BoltClock
Visual Studio doesn't strike through anything by default. I remember Resharper doing such things though.
dtb
@Bolt: but no mouseover text, errors, warnings at all? Hmm. The thread Richard links to, if accurate, seems to indicate that the warning for `ToString(IFormatProvider)` is being shown in error. Joel, what third-party plugins (resharper, etc, as dtb mentions) are you using? I can't reproduce that at home with 08 or 10, but I don't have any plugins here.
Michael Petrotta
@Michael... I added a screen shot
JoelFan