Article ID: 305814 - Last Review: July 16, 2008 - Revision: 4.0 How to pass optional method arguments from C#This article was previously published under Q305814 On This PageSUMMARY
This step-by-step article shows you how to take advantage of optional method arguments.
C# does not support optional method arguments. However, there may be times when you are using components that were created in a language that supports optional arguments, such as legacy COM components or components created with Microsoft Visual Basic .NET.
For the purpose of illustration, the Navigate2 method of SHDocVw.IWebBroswer2 is used. Only the first of the five arguments to this method is required; the remaining four are optional. RequirementsThe following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
Declare an object of type "Missing"Pass the "Missing" object as an argumentThe Navigate2 method requires that arguments be passed by reference. Check the documentation for the method that you are using to determine if the arguments need to passed by value or by reference.Set project references (optional)The code sample in the "Complete code sample" section is used to illustrate this technique. This code sample does not run as is. If you want to try this code, you have to perform two additional steps:
Complete code sample | Article Translations
|
Back to the top
