String.Empty
First, String.Empty
is the same as ""
. Who says it's different, has advantages, does not know the implementation and is inventing things (until it has already been different in the past by implementation internal). What the person can, is to say that it becomes more readable, clearer that you want an empty string to be created there. Some will say that it's easy for you to look at ""
and " "
and find that it's the same thing. This I can understand. Although I think exaggeration.
Selecting Rules in Visual Studio
You should know that this information can be selectively turned off, right? If you do not like some rule and do not want to follow it, hang up. If you want some of your own, you can add it to the VS code analysis system.
Names rule
There is no difference and it is only a decision that one must take to avoid each one doing his own thing. That's why the rule exists.
I've never been able to find a reason to clearly choose one over the other. Since the language prefers to have an alias for the BCL class, it prefers to use it. Too bad that Microsoft does not follow its codes:)
Use of class names
There is a recommendation to use class names when some class or class member needs to carry the type name. Example: PrintInt32
is better and not Print_int
or worse, Printint
. So it is easy for other languages that run on top of the CLR to understand what it refers to since int
is something exclusive of C # and not platform. Int32
is the type name throughout the CLS . This applies to all language type alias .
In local or even private variable names (may be a problem in case of reflection, but it is rarely problematic) is not a problem and it is preferable to use the name described by the language. In expressions, as in the example of the question, which is something that does not leak for use in other languages, the option is by the form of the language.
Some might find it more consistent to use only the class name since there are cases where it is best. It makes sense, but the option was made back there to make it easier for those coming from C / C ++ / Java.