Conclusion

 <  Day Day Up  >  

Fields provide storage for information within classes and structures. Properties allow calculated information to be exposed as if they were fields and enable validation of information as it is assigned to a field. The next chapter discusses events, which are a way for types to provide notifications to other types. It also discusses delegates, which are references to methods .

Here are some style points to consider.

  • When a programmer creates a Private field to store the information for a Public property, a common naming convention is to use the property name with a leading underscore . For example, a Public property named Total would be stored in a Private field named _Total .

  • Previous versions of Visual Basic allowed indexed property parameters to be reference parameters. This is now disallowed because the .NET Framework does not allow indexed properties to modify index arguments.

  • Previous versions of Visual Basic allowed defining default properties without parameters because the language distinguished between value assignment ( Let ) and reference assignment ( Set ). Without this distinction, it would be impossible to assign to a variable of a type with a parameterless default property because there would be no way to tell whether the assignment was to the variable or to the default property. Default parameterless properties on COM objects can still be accessed by adding parentheses after the value (i.e., obj() will call the default parameterless property, if any, of the variable obj ).

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net