Why can't I give a default value as optional parameter except null?
I want to have a optional parameter and set it to default value that I determine, when I do this: private void Process(Foo f = new Foo()) { } I'm getting the following error ( Foo is a class): 'f' is type of Foo, A default parameter of a reference type other than string can only be initialized with null. If I change Foo to struct then it works but with only default parameterless constructor. I read the documentation and it's clearly states that I cannot do this but it doesn't mention why? , Why is this restriction exists and why string is excluded from this? Why the value of an optional