Why would I ever want to do this:
public T X { get; set; }
Instead of this:
public T X;
People (including some answers on SO) have told me that "What if you wanna change the behavior later on?" is an answer to this, but that's not true, since I can just convert my public T X;
into
public T X {
get { blabla; }
set { blybly; }
}
Edit: Before posting anymore links about "Read this" and "Read that", you can check the links. 99% of them contain mostly other people referring to other links, and nobody actually gives a proper reason to use properties over fields.
Here's one example of a popular answer: "You can make the setter private
public T X { get; private set; }
Well obviously if I want a private setter, I will create a property. But if I don't, why not just use a field? And if I later decide I want a private setter, why couldn't I change my field from public T X;
to public T X {get; private set; }
?