Help me resolve the dispute here.
It:
SqlCommand cmd = new SqlCommand( "sql cmd", conn);
handled exactly the same as this:
const string s = "sql cmd"; SqlCommand cmd = new SqlCommand( s, conn);
Those. it matters if I specifically declare that string s is a constant.
And if it is not treated equally, why not?
In the last fragment, this does not mean that the string const is a const variable. This is not exactly the same as const in C ++. (Strings are always immutable in .NET.)
, . , s, ( ), . , - , "sql cmd" , ... , , , , PDB, .
s
a const , , .
const
, , - a const, , ( - ).
SqlCommand "" - .
, .
, Reflector, , . , :)
100%, , .
const , , , .
, , , , .
However, some evidence will study the IL code generated in both cases.