S
Sathyaish
/* I am writing this C# program because I forgot the syntax for
calling a parameterized constructor from a non-parameterized one
within the same class.
I was coding in Java and just typed it like this:
public MyClass(String someParam)
{
}
public MyClass()
{
this.MyClass("Someparam");
}
The compiler complained and I remembered it was like this in Java:
public MyClass()
{
this("Someparam");
}
This led me to think that I am forgetting the way it is done in C#
and that my mistake was influenced by the way it is done in C#. Just
so that I do not forget how to do it in C#, I am writing this small
spike solution as a reminder.
I have now tried
this.MyClass("SomeParam");
MyClass("SomeParam"); and
this("SomeParam");
None of them seem to work. What's the correct way. I realize I have
forgotten the correct way.
*/
calling a parameterized constructor from a non-parameterized one
within the same class.
I was coding in Java and just typed it like this:
public MyClass(String someParam)
{
}
public MyClass()
{
this.MyClass("Someparam");
}
The compiler complained and I remembered it was like this in Java:
public MyClass()
{
this("Someparam");
}
This led me to think that I am forgetting the way it is done in C#
and that my mistake was influenced by the way it is done in C#. Just
so that I do not forget how to do it in C#, I am writing this small
spike solution as a reminder.
I have now tried
this.MyClass("SomeParam");
MyClass("SomeParam"); and
this("SomeParam");
None of them seem to work. What's the correct way. I realize I have
forgotten the correct way.
*/