deep explanation!
{get; set;} is an automatic property, and the second is a field.
a field is a normal variable of some type that contains data.
a property is several methods (sometimes sometimes it is one), one for get and one for set. they have only syntax similar to fields, but in fact they are completely different.
properties are usually used to filter a set of values ββor virtualize something in get, etc.
automatic properties, also create a private field behind the scenes, return its value to get and set its value to the set.
this seems like a normal field, but behind the scenes (IL) using properties is completely different from using fields.
a.Property1 = 4;
translates into something like:
a.Set_Propert1(4);
and this:
x = a.Property1;
translates to the following:
x = a.Get_Property1();
So, why is it good practice to use only public properties, even if they are automatic?
let's say that you are writing a library that is being used by another application, and someday you will want to release a new version of this library that restricts one of the fields of your class.
If you use properties, you can simply change the property (even if it is automatic, you can replace it with a full one), and then any application that used your library can still use it in the same way.
but if you created a public field that you now want to limit, you need to create a property for this and make the field private, but if you want, any application that used your library will no longer be used because the way the fields and properties are used is different.