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?
views:
114answers:
1
+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
2010-10-04 22:10:26
Specifically, the no-arg overload (`ToString()`) that the OP is using is **not** deprecated.
Michael Petrotta
2010-10-04 22:11:29
Well, Intellisense strikes out "ToString" even before I expand the overloads
JoelFan
2010-10-04 22:11:33
@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
2010-10-04 22:12:14
These guys have a similar experience: http://channel9.msdn.com/forums/Coffeehouse/250182-deprecated-string-EnumToStringIFormatProvider-provider/
Richard Cook
2010-10-04 22:12:16
@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
2010-10-04 22:14:04
Visual Studio doesn't strike through anything by default. I remember Resharper doing such things though.
dtb
2010-10-04 22:15:42
@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
2010-10-04 22:15:47
@Michael... I added a screen shot
JoelFan
2010-10-04 22:16:45