1

Possible Duplicate:
C#: Public Fields versus Automatic Properties

just basic question here. I fail to understand the need or the difference between automatic properties VS regular local variable

Class abc {
//automatic properties
Public int  serial_number { get; set;}

//Regular local variable
Public int serial_number2;
}

I know mostly we use automatic properties for constructor initial value. But we can do the same thing with local variable Can anyone explain this to me? Pros vs cons?

Thanks

Community
  • 1
  • 1
John Ryann
  • 2,283
  • 11
  • 43
  • 60
  • 3
    That's a field, not a local variable. – BoltClock Oct 03 '11 at 16:50
  • Google is your friend. Also, this is a dupe of a LOT of questions. For example, read this : http://stackoverflow.com/questions/1180860/c-public-fields-versus-automatic-properties – Tipx Oct 03 '11 at 16:58
  • @Tipx: your comment is a dupe of my close vote. – BoltClock Oct 03 '11 at 17:05
  • @BoltClock: Look at my rep, look at the site privileges. You'll see that I'm high enough to see the votes when a post is closed, but not high enough to see when it's being closed. – Tipx Oct 03 '11 at 17:15

0 Answers0