Setting the default value of a C# Optional Parameter

Posted by Jaxidian on Stack Overflow See other posts from Stack Overflow or by Jaxidian
Published on 2010-04-28T13:07:16Z Indexed on 2010/04/28 13:13 UTC
Read the original article Hit count: 294

Filed under:
|
|

Whenever I attempt to set the default value of an optional parameter to something in a resource file, I get a compile-time error of Default parameter value for 'message' must be a compile-time constant. Is there any way that I can change how the resource files work to make this possible?

    public void ValidationError(string fieldName, string message = ValidationMessages.ContactNotFound)

In this, ValidationMessages is a resource file.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .net-4.0