Avatar ·

In C# for string initialization: string.Empty, String.Empty or "" — which is better?

Hello everyone! I just started learning C# and encountered a question that really confuses me. When I need to declare an empty string, I see three options in different code examples:

string a = "";
string b = string.Empty;
string c = String.Empty;

They all work the same way and create an empty string. But which one is considered correct in terms of style, performance, and readability? I've heard that "" might create a new object each time, while string.Empty is a constant. Is that true? Or is it all just prejudice?

I'm also interested in whether there is a difference between string.Empty and String.Empty? After all, string is an alias for System.String. So they are equivalent, right? But if so, why does the C# community more often use string.Empty?

And lastly: does the choice affect performance in loops or with frequent assignments? For example, if I in a loop of