String Empty.
First, String.Empty
is the same thing as ""
. Who says it’s different or has advantages, does not know the implementation and is inventing things (has even been different in the past by internal implementation). What one can, is to say that it becomes more readable, more clear that you want a string empty be created there. Some will say it’s easy for you to look at ""
and to " "
and think it’s the same thing. This I can understand. Although I find exaggeration.
Selection of rules in Visual Studio
You should know that this information can be selectively turned off, right? If you don’t like some rule and don’t want to follow it, hang up. If you want one of your own, you can add it to the VS code analysis system.
Rule of names
There is no difference and it is only a decision that must be made to avoid each one doing his own way. Therefore the rule exists.
I could never find a reason to clearly choose one over the other. As the language preferred to have one alias for the BCL class, it is preferred to use it. Pity that even Microsoft does not follow it in its codes :)
Use of class names
There is a recommendation to use class names when some class or class member needs to take the type name. Example: it is better PrintInt32
and not Print_int
or worse, Printint
. This makes it easy for other languages that run on top of the CLR to understand what you are referring to since the int
is something exclusive to C# and not the platform (but I don’t buy this much anymore). Int32
is the name of the guy all over CLS. That goes for all alias of language types.
In names of local or even private variables is no problem (may be problem in case of reflection, but it is rare to be) and it is preferable to use the name described by the language. In expressions, as in the question example, which is something that does not leak for use in other languages, the option is by the form of the language.
Some may think it would be more consistent to use only the class names since there are cases where it is better. It makes sense, but the option was made back there to make it easier for those coming from C/C++/Java.
I will let someone with more knowledge in the language answer, but take a look at this question of Soen, I believe it will help to clarify a little your doubt: http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string
– Marcelo de Andrade
Did any help you more? You need something to be improved?
– Maniero