In C# I usually use String
when I\'m utilizing a method and string
when declaring a variable. I read elsewhere that this is the preferred method to
Because it doesn't require using System;
at the top.
Because you didn't uncheck "Prefer intrinsic predefined type keyword when declaring locals, parameters and members" found under Tools > Options > Text Editor > C# > Code Style
VS2017-2019 Tools > Options > Text Editor > C# > Code Style (>predefined type preferences:) > For member access expressions
select "Prefer framework type"
VS2015 Tools > Options > Text Editor > C# > Code Style
uncheck "Prefer intrinsic predefined type keyword in member access expressions"
Example given in VS2015-2019 for this option flips
var local = int.MaxValue
(Prefer predefined type /ticked)
to
var local = Int32.MaxValue
(Prefer framework type /unticked)
ReSharper - to disable it/configure the inspection severity, it is the "Replace built-in type reference with a CLR type name or a keyword" rule.
Now nothing hints at me to change String.Format()
to string.Format()
string is an alias in C# for System.String. So technically, there is no difference. It's kinda like int vs. System.Int32.
As far as the what you 'Should' do, string is the preferred object for variables and String for classes as it the practised choice.
usually seen like this
string example = "hello world";
string example = String.Format("Hello World {0}!", example);