c# - Honestly, what's the difference between public variable and public property accessor? -


possible duplicates:
what difference between field , property in c#
should use public properties , private fields or public fields data?

what difference between:

public string vara; 

and

public string vara { get; set; } 

the public property accessor gives more flexibility in future.

if want add validation setting value, write non-default setter. none of other code have modified.

there reasons you'd want replace default getter code. can real pain public variable.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -