How do I check if an optional argument was passed to a method?
public void ExampleMethod(int required, string optionalstr = \"default string\",
int optio
You can't check that, because method with optional parameters is a regular method with all parameters, including those which have default values. So, your method will be compiled into:
public void ExampleMethod(int required, string optionalstr, int optionalint)
{
}
Default values are inserted by compiler in the call point. If you'll write
ExampleMethod(42);
Then compiler will generate call
ExampleMethod(42, "default string", 10);
You can compare if optionalstr or optionalint has value equal to default value, but you can't really say if it was provided by compiler or by developer.