In C#, should I use string.Empty or String.Empty or “” to intitialize a string?

前端 未结 30 2904
挽巷
挽巷 2020-11-22 02:06

In C#, I want to initialize a string value with an empty string.

How should I do this? What is the right way, and why?

string willi = string.Empty;
         


        
30条回答
  •  星月不相逢
    2020-11-22 02:52

    No one mentioned that in VisualStudio String is color coded differently then string. Which is important for readability. Also, lower case is usually used for vars and type, not a big deal but String.Empty is a constant and not a var or type.

提交回复
热议问题