Parentheses or just Quotes?
Okay, so I've known about this for like 600 years now, b开发者_运维知识库ut I've only just now cared to wonder why.
Why, in C# can we assign to a string like this?:
string f = "u";
AND ALSO:
string n = ("ny");
Is there any difference? I've not noticed any, but I always use ""; without the parentheses.
There is not any difference. The parenthesis can be used in any expression to explicitly define precedence of the operations. For your simple case, the expression is the string itself, so there is no need for the parenthesis. There is no difference in the compiled IL.
精彩评论