I have to make call to VB.NET or legacy COM components (Interop wrapper will be created for it.). Fairly often, there are methods with optional parameters. Unlike VB.NET or VB, C# does not support optional parameter. Then, how should I call these methods?
C# forces you to specify all the parameters when calling a method. This means that you have to pass in something for the optional parameter.
You could look into document to figure out the default value of the parameter and pass it in. Sometimes, the value you passed in does not matter. You can pass in a dummy value. Make sure pass in the right data type.
If the parameter is using the type "object" (or "variant" from VB/COM standpoint), there is a shortcut, you can just pass in this value:
If you need do this often, you could define it as a read-only member variable and use this variable instead, like this:
readonly object def = System.Reflection.Missing.Value;
Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.