As far as I know when I use automatically implemented properties with struct I should explicitly chain the parameterless constructor (ie the parameterless constructor has to be called before auto implemented properties can be assigned). Now I have the following code that works correctly without chaining : this()
public struct Foo
{
public int Value { get; private set; }
public Foo(int value) //: this()
{
Value = value;
}
}
static void Main(string[] args)
{
Foo f = new Foo(33);
Console.WriteLine(f.Value);
}
I found similar post here where the user was getting a compiler error, and it was suggested to use : this()
in order to fix the problem. Why my code works without : this()
? Should we use or not use : this()
?
Thanks