Let's say that you have to use an constructor to initialize some fields...
class Foo
{
private int price;
public Foo(int price)
{
this.price = price;
}
}
I know that usually the constructor initializes some fields but what's the difference if I initialize properties with it. For example
class Foo
{
private int price { get; set; }
public Foo(int price)
{
this.price = price;
}
}
The code seems to work the same but my question is if this is good practice and should I do it ?