
Function parameter default value?
Quote:
> >Is it possible in C# smth like default values for parameters (as we had
in
> >C++)
> >void Function1(int nVar1, char chVar2, int nVar3 = 1)
You don't have default function parameters but there is a way around to have
default parameters in case of constructors. you can assign values to your
instance variables at the point of declaration itelf. in most of the cases,
this should serve your purpose (the exception being when you have overloaded
c'tor where you want to specify different default values. why you would want
to do that is a diff. question).
regards
mrinal
Quote:
> Serge,
> >Is it possible in C# smth like default values for parameters (as we had
in
> >C++)
> >void Function1(int nVar1, char chVar2, int nVar3 = 1)
> >Is it possible to assign default value in C#?
> No, you have to use overloading instead:
> void Function1(int nVar1, char chVar2) {
> Function1( nVar1, chVar2, 1 );
> }
> void Function1(int nVar1, char chVar2, int nVar3) { ... }
> Mattias
> ===
> http://www.msjogren.net/dotnet/
> Please reply only to the newsgroup.