`
talin2010
  • 浏览: 522591 次
  • 性别: Icon_minigender_1
  • 来自: 河北
社区版块
存档分类
最新评论

17.6 Properties

阅读更多
A property is a member that provides access to an attribute of an object or
a class. Examples of properties include
the length of a string, the size of a font, the caption of a window, the
name of a customer, and so on. Properties
are a natural extension of fields?both are named members with associated
types, and the syntax for accessing
fields and properties is the same. However, unlike fields, properties do
not denote storage locations. Instead,
properties have accessors that specify the statements to be executed when
their values are read or written.
Properties thus provide a mechanism for associating actions with the
reading and writing of an object?s attributes;
furthermore, they permit such attributes to be computed.
Properties are declared using property-declarations:
property-declaration:
attributesopt property-modifiersopt type member-name {
accessor-declarations }
property-modifiers:
property-modifier
property-modifiers property-modifier
C# LANGUAGE SPECIFICATION
240
property-modifier:
new
public
protected
internal
private
static
virtual
sealed
override
abstract
extern
member-name:
identifier
interface-type . identifier
A property-declaration may include a set of attributes (§24) and a valid
combination of the four access modifiers
(§17.2.3), the new (§17.2.2), static (§17.6.1), virtual (§17.5.3, §17.6.
3), override (§17.5.4, §17.6.3),
sealed (§17.5.5), abstract (§17.5.6, §17.6.3), and extern modifiers.
Property declarations are subject to the same rules as method declarations (
§17.5) with regard to valid
combinations of modifiers.
The type of a property declaration specifies the type of the property
introduced by the declaration, and the
member-name specifies the name of the property. Unless the property is an
explicit interface member
implementation, the member-name is simply an identifier. For an explicit
interface member implementation
(§20.4.1), the member-name consists of an interface-type followed by a ?.?
and an identifier.
The type of a property must be at least as accessible as the property
itself (§10.5.4).
The accessor-declarations, which must be enclosed in ?{? and ?}? tokens,
declare the accessors (§17.6.2) of the
property. The accessors specify the executable statements associated with
reading and writing the property.
Even though the syntax for accessing a property is the same as that for a
field, a property is not classified as a
variable. Thus, it is not possible to pass a property as a ref or out
argument.
When a property declaration includes an extern modifier, the property is
said to be an external property.
Because an external property declaration provides no actual implementation,
each of its accessor-declarations
consists of a semicolon.
分享到:
评论

相关推荐

    The art of Molecular Dynamics Simulations ,2nd Edition,Rapaport

    17.6 Techniques for vector processing 473 17.7 Further study 480 18 More about software 481 18.1 Introduction 481 18.2 Structures and macro definitions 481 18.3 Allocating arrays 487 18.4 Utility ...

    Mathematical Methods for Physicists 第六版

    17.6 Lagrangian Multipliers 1060 17.7 Variation with Constraints 1065 17.8 Rayleigh-Ritz Variational Technique 1072 Additional Readings 1076 18 Nonlinear Methods and Chaos 1079 18.1 Introduction ...

    Cadence 学习笔记-----给元件添加Footprint

    如果你需要对元件库中的所有实例都应用新的封装,可以先打开元件库文件,找到相应的元件,通过菜单栏的"Options" -> "Package Properties"路径,输入新的PCB封装。完成修改后,返回原理图,选择"Replace Cache"操作...

    visio教程PDF

    12.1.2 Properties对话框 12.1.3 后继保存 12.1.4 打印到文件 12.2 小结 第13章 打开绘图文件 13.1 打开已存在的Visio绘图文件 13.1.1 在启动时打开一个已存在的文件 13.1.2 在启动后打开一个已...

    javascript权威指南(第六版)

    17.6 Mousewheel Events 471 17.7 Drag and Drop Events 474 17.8 Text Events 481 17.9 Keyboard Events 484 18. Scripted ...

    Visio 2000 技术大全

    12.1.2 Properties对话框 12.1.3 后继保存 12.1.4 打印到文件 12.2 小结 第13章 打开绘图文件 13.1 打开已存在的Visio绘图文件 13.1.1 在启动时打开一个已存在的文件 13.1.2 在启动后...

    Multiple View Geometry in Computer Vision Second Edition

    17.6 Number of independent equations 428 17.7 Choosing equations 431 17.8 Closure 432 18 N-View Computational Methods 434 18.1 Projective reconstruction – bundle adjustment 434 18.2 Affine ...

    Printed Circuits Handbook

    17.6 Modeling the Thermal Performance of the PCB / 17.15 References / 17.18 Chapter 18. Information Formating and Exchange 18.1 18.1 Introduction to Data Exchange / 18.1 18.2 The Data Exchange Process...

    Maven权威指南 很精典的学习教程,比ANT更好用

    Interpolation of Properties in Dependency Output Location 12.5.4.3. Including and Excluding Dependencies by Scope 12.5.4.4. Fine Tuning: Dependency Includes and Excludes 12.5.4.5. Transitive ...

    The Algorithm Design Manual (2rd Edition)

    2.7 Properties of Logarithms 2.8 War Story: Mystery of the Pyramids 2.9 Advanced Analysis (*) 2.10 Exercises 3 Data Structures 3.1 Contiguous vs. Linked Data Structures 3.2 Stacks and Queues ...

    信息论基础(英文版)

    17.6 Entropy Rates of Subsets 667 17.7 Entropy and Fisher Information 671 17.8 Entropy Power Inequality and Brunn–Minkowski Inequality 674 17.9 Inequalities for Determinants 679 CONTENTS xiii 17.10 ...

    Mathematics for Computer Science 2017.7z

    17.6 References 18 条件概率(Conditional Probability) 18.1 Monty Hall Confusion 18.2 定义和符号(Definition and Notation) 18.3 条件概率的四步法(The Four-Step Method for Conditional Probability) ...

    The_Linux_Networking_Architecture

    Section 17.6. Multicast Transport Protocols 364 Chapter 18. Using Traffic Control to Support Quality of Service (QoS) 366 Section 18.1. Introduction 366 Section 18.2. Basic Structure of Traffic...

    ZendFramework中文文档

    1. Introduction to Zend Framework 1.1. 概述 1.2. 安装 2. Zend_Acl 2.1. 简介 2.1.1. 关于资源(Resource) 2.1.2. 关于角色(Role) 2.1.3. 创建访问控制列表(ACL) ...2.1.5. 定义访问控制 ...

    The.Linux.Networking.Architecture

    Section 17.6. Multicast Transport Protocols 364 Chapter 18. Using Traffic Control to Support Quality of Service (QoS) 366 Section 18.1. Introduction 366 Section 18.2. Basic Structure of ...

    Programming Excel With Vba And .net.chm

    Create Properties Section 5.4. Define Enumerations Section 5.5. Raise Events Section 5.6. Collect Objects Section 5.7. Expose Objects Section 5.8. Destroy Objects Section 5.9. Things You ...

    Applications of Classical Physics

    24.6 Properties of the Riemann curvature tensor 24.7 Curvature Coupling Delicacies in the Equivalence Principle, gravitational Laws of Physics in Curved Spacetime and some Non- 24.8 The Einstein ...

    UNIX环境高级编程(第二版,英文版)

    此书为英文版,但对于大家应该不会有阅读障碍。 此书对于linux环境编程的同志应该是必读的书,目录如下: ... Praise for Advanced Programming in the UNIX® Environment, Second Edition Praise for the First ...

Global site tag (gtag.js) - Google Analytics