You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That is effectively a limitation inherited by the CLR. The default value must be encoded into the metadata of the parameter at compile time and available to allow any compiler to use that value in place of omitted arguments at the call site. There is no way to encode an expression that would be understood by the CLR or universally understood by CLR languages.
The argument could be made that for private or internal methods that the C# compiler could relax that restriction since the optional parameter metadata would never be a part of the public surface of the assembly. In those cases the compiler could contain a dictionary of the expressions and then replace the omitted arguments.
make an optional parameter without having a constand but like this:
public void Draw(Color c = Color.White) {
}
The text was updated successfully, but these errors were encountered: