Hello stackoverflow,
Recently, after reading a lot of tutorials around the Internet, I've noticed that some developers skips writing the fields in their model classes and just go with properties, like this:
public class MyClass
{
public string MyProperty { get; private set; }
}
What exactly is the benefit of doing this, apart from writing less code that is? While I do realize that the setter is private, isn't there some kind of security issues when you don't specify your private fields? In other words: what's the best practice here? Writing model classes without fields and related properties, or just go with these public properties without the fields?
Thanks in advance,
Bo