Can seems to be strange, but is there a way to declare or convert variable to constante something like :
string myVariable = "MyString";
const string myConstant = myVariable ;
I need this to answer to my problem: linq to sql startwith performance indexed columns
thanks
no there is no way to do this for Const
Const values are burned directly into the call-site at compile time, Instead you could make it readonly
and assign it in the constructor
something like
string myVariable = "MyString";
readonly string myConstant="test" ;
public MyClass()
{
myConstant= myVariable ;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With