Optional parameters

F

Frank Rizzo

Does c# support optional parameters in function declarations?
Does it support assignment of default values to arguments, in particular
optional parameters?
If so, can someone point me to or provide an example.


For instance in vb6, you could do the following:
function DoStuff(optional ID as integer = 10, optional Name as string =
"test")
....
end function
 
I

Ignacio Machin

Hi Frank,

I do not think so, you can overload the function, though :

public void DoStuff(){
DoStuff( 10, "test");
}
public void DoStuff( int i, string s){}

Hope this help,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top