Optional parameters for functions in c#


C# (before .net 4.0) 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.

class Example {    public void Test()     {        object missing = Type.Missing;       object urlblog = "http://blog.bugrapostaci.com";        VBTestService yourObject = new VBTestService();         // first parameter is url and other 3 are optional in definition of OptionalParameterFuction coded VB        yourObject.OptionalParameterFuction(ref urlblog, ref missing, ref missing, ref missing, ref missing);     } }

Happy Codding…

Advertisements

About bpostaci
Sr. Support Escalation Engineer in Microsoft.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: