I have used two ways for setting up a public class in C# (and VB.NET)
Option 1 - Setters & Getters
public class foo
{
private string _bar;
public string bar
{
get { return _bar; }
set { _bar = value; }
}
}
Option 2 - Simple Public Class
Public Class foo
Public string bar = "";
End Class
I've done it both ways, but it's much simpler and less code with Option 2 - and I don't see the difference in terms of other coding to set or get values for the class or performance - both ways work just fine.
My question is "Why would you do Option 1 if there are not some other 'special things' happening in the getter or setter? And if so - what would those reasons potentially be?
What I want to know if there's some 'Convincing Argument' for using setters and getters for this and if so 'Specifically Why?
Cheers, Charlez