Brackets or just quotes?

Well, that’s why I know about it after about 600 years, but only now it became interesting for me to find out why.

Why can we assign such a line in C # ?:

string f = "u";

AND ALSO:

string n = ("ny");

Is there any difference? I did not notice this, but I always use ""; without parentheses.

+3
source share
1 answer

There is no difference. A bracket can be used in any expression to explicitly prioritize operations. For your simple case, the expression is the string itself, so there is no need for parentheses. There is no difference in compiled IL.

+10
source

All Articles