>If a method is created like below, how does ":this()" at the end change the result? why can it be needed at all?
>
> public Product(int new_id, short product_name, string product_type) : this()
>
>Thanks
The this() at the end is executing the (code of the) parameterless constructor before the code of public Product(int new_id, short product_name, string product_type)
Example - execute this - you will see that Prop1 is set before Prop2
public static class qqq
{
static void Main()
{
A a = new A(23);
Console.ReadLine();
}
}
class A
{
int Prop1;
int Prop2;
public A()
{
Prop1 = 1;
Console.WriteLine("prop1");
}
public A(int x)
: this()
{
Prop2 = x;
Console.WriteLine("prop2");
}
}
Gregory