I was trying to find meaning of this terms but especially due to language barrier I was not able to understand what they are used for. I assume that "field" is variable (object too?) in the class while "property" is just an object that returns specific value and cannot contain methods etc. By "member" I understand any object that is declared on the class level. But these are just my assumptions based on commented code samples where some careful programmers used "property region" etc. I would really appreciate if someone could explain it to me.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
The terminology in this area is hopelessly jumbled and varies wildly from language to language, and model to model. Do you have a specific language or platform in mind?
To a first approximation:
In C# :
fields : These are variables declared at the class level.
properties : Often used as accessors to a private field of a class, they can provide get and set methods that wrap some logic around the field manipulation.
members : Includes fields, properties, methods, events of a class.
Those terms span different languages and therefore they overlap quite a bit and the differences are more about the concrete languages than about the concept. Property and field are used to describe data in classes, members can be data and behavior (e.g. methods) in classes. However, there are differences between properties and fields in C# and Java, but that is syntactic sugar. If you were using a prototype based object oriented language (as opposed to a class-based) you would talk about slots of objects... If you want to get a grasp of the entire meaning, first choose a language.