3

I have Visual Studio 2015 with the latest version of Reshaper (9.1.2).

I tend to use a style of referring to Types and type aliases much the way this answer describes. I like the general look of making variable declarations with the type alias and using the System type for expressing static functions that exist for the type.

As an example:

string greet = String.Format("Hello {0}!", place);

With that said, I'm seeing a Roslyn Code Fix in my IDE to replace String for string. Before Roslyn improvement

It asks to simplify...

Roslyn Simplify name 'String'

And it comes out changing only the String to string:'String' changed to 'string'

I want to what this change affects, and why.

  • Is it a performance improvement in compilation only?
  • Does it add some minor speed benefits at runtime?
  • Is there any other reason why I should care about this code improvement?
Community
  • 1
  • 1
Zachary Dow
  • 1,639
  • 18
  • 34

1 Answers1

6

So, even now in the latest version of Visual Studio (2015) and the .NET (4.6) framework, string is still just an alias for String. It's simply a style suggestion from Visual Studio.

For anyone else who may want to remove this code style...

This setting can be turned off under: Tools => Options... => Text Editor => C# => Code Style => Prefer intrinsic predefined type keyword in member access expresssions.

Setting visual

Zachary Dow
  • 1,639
  • 18
  • 34