1) C# does not allow to default parameters; however you can implement it overloading methods:
public void myMethod(int x, int y) { // Do something } public void myMethod(int x) { myMethod(x, 50); } 2) Yes, you can call the other constructor using this: class myClass { public myClass(int val) { // Do something } public myClass(): this ( 50 ) { } } Federico Raggi Latin America Developers Initiative Manager "Don't take me too seriously, I'm in Marketing" Microsoft Phone: (954)489-4862 Mobile: (954)465-4862 > -----Original Message----- > From: Collins, Michael G [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 05, 2002 3:44 PM > To: [EMAIL PROTECTED] > Subject: [DOTNET] OT: Is it possible to use default values in C# like the > Optional parameters in VB.NET? > > Is it possible to use default values in C# like the Optional parameters in > VB.NET? > > VB.NET (From Beta 2 source example: > Optional ByVal Events As Boolean = True > > > Old style C++ sample: > Bool Events = true > > > Can this be done in C#? Or do I need to create 2 versions of the function? > > > Also, > > If I have 3 different constructors, is it possible to call one construtor > from another? Or should I call a single init routine from each > constructor? > > Example: > public class xx > { > private int val1; > private int val2; > private int val3; > > public xx() > { > xx(0,0,0); > } > > public xx( int v1 ) > { > xx(v1,0,0); > } > > public xx( int v1, int v2, int v3 ) > { > val1 = v1; > val2 = v2; > val3 = v3; > } > } > > 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.