Instead, you can try:
switch(filter ?? String.Empty)
string.Empty is a read-only field, while "" is a compile-time constant. You can also read the article here in the Code Project String.Empty Internals
//The Empty constant holds the empty string value. //We need to call the String constructor so that the compiler doesn't //mark this as a literal. //Marking this as a literal would mean that it doesn't show up as a field //which we can access from native. public static readonly String Empty = "";
On a side note:
You will also see this problem when you provide a default parameter value inside your method (C # 4.0):
void myMethod(string filter = string.Empty){}
The above will result in a compile-time error, since the default value must be constant.
source share