Variables are storage locations that data can be stored in. They are are a way of naming data locations that can be later on used in the program. Variables generally have four attributes: an identifier, data location, type and value. We have used variables in most of our programs in class, for example, storing names as strings and numbers as doubles/ints.
Properties on the other hand can be looked as a special type of method that exposes a variable. A property can have can have a Get procedure (read only), a Set procedure (write only), or both (read-write). Properties are effective in a way that they have access to private data inside of a class, and can manipulate the data as it enters or leaves the class.
Variables and properties are both important in programming because they help store and manipulate data. Variables can be used to store and protect important user data inside of classes, and the property of those variables help manage what data is only going out into outside classes. I feel like as programs get bigger we will be creating greater amounts of classes that will have to share data, and variables and properties will become important as to what data is going to be shared and protected.
Sources:
https://www.techopedia.com/definition/25647/variable-programming
http://stackoverflow.com/questions/4142867/what-is-difference-between-property-and-variable-in-c-sharp
Comments
Post a Comment