0

I just upgraded to VS 2015 and its complaining about me using the capital String version of string, saying it can be simplified.

I tried googling for IDE0001 and clicking the link but neither gave me any good info on why this is a thing. CS0168 appears to be unrelated as well (https://msdn.microsoft.com/en-us/library/tf85t6e4(v=vs.90).aspx)

Is there any reason to use the lower case version over the upper case version?

enter image description here

Not loved
  • 30,848
  • 21
  • 111
  • 180
  • 2
    `String` is a .NET type and `string` is a C# data type. The latter is an alias for the former. Theoretically, that could change and it could alias a different type but that will never actually happen. Personally, I always use C# data types in place of .NET types when they exist. Some argue that you should use the .NET type when invoking static members and C# data types for instances. It makes no difference to the compiled code so you should come up with a convention you're happy with and stick to it. – jmcilhinney Aug 04 '15 at 02:08
  • I basically agree with @jmcilhinney but IMO it seems silly to use one variant for one usage, and another variant for another when the two constructs are exactly identical in effect. Does it *really* make sense to use `Int32.Parse` rather than `int.Parse`? It seems to me that using the two different tokens for separate purposes when those two tokens are identical does nothing but sow confusion. – Kirk Woll Aug 04 '15 at 02:23
  • @KirkWoll, I can see the logic behind using .NET types for static members but I don't find it compelling enough to do so. If nothing else, it means that you have to think about what context you're in and might then make mistakes if you don't. – jmcilhinney Aug 04 '15 at 03:30

0 Answers0