Note that if the optional parameters are System.Objects (VARIANTs), or
if you're willing to do a late-bound call, you can just pass
Type.Missing for each optional parameter instead of figuring out and
passing the default value for each one.

-----Original Message-----
From: Tom Archer [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, May 05, 2002 6:07 PM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] CSharp and optional parameters

That's correct. Default parameters are not supported in C#. This was
done
for a couple of reasons. However, the main reason is for versioning.

Per Joe Nalewabau (Product Manager for C#)
"Default parameters were not added due to the versioning issues
associated with them. Essentially when you add default parameters the
compiler essentially burns the default value in to the callers code when
the code is compiled. This means that if you change the default values
all clients must be recompiled to take advantage of the new value -
rather than have the class library itself decide what the default values
should be."

You could write a wrapper method that only takes the params you would
normally change and calls the wrapped method with the default params.

Cheers,
Tom Archer
Author - Inside C#

-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of
Kirk Jackson
Sent: Monday, May 06, 2002 9:01 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] CSharp and optional parameters


Hi,

When using old DLL's from within C#, there are some methods that take
optional parameters. In VB you can just leave those parameters out, but
in C# it seems that you have to give values for every parameter, meaning
that you need to figure out what each default value is (somehow!).

Is this correct?

Thanks,

Kirk

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to