Stackoverflow:
https://stackoverflow.com/questions/5096926/what-is-the-get-set-syntax-in-c
Just to add something... If you don't put
{get; set;}
you are creating a Field but if you put the{get; set;}
you are creating a Property. Having a property could make some things easier especially when working with Reflection.
如果加了 {get; set;}
那么在创建 Property
,如果不加就是在创建 Field
。Field
在 Data Binding
的时候不会起作用,必须要用 Property
。