O'Reilly logo

Visual Basic .NET Programming Language, The by Paul Vick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Fields and Properties

The previous chapter discussed executable statements (methods) as type members, so now it is worth talking about variables as type members. Like local variables, which are locations to store information in methods, fields and properties are locations that store information in classes or structures.

Fields

A field is a variable that lives in a class or a structure instead of inside a method. Fields are declared in exactly the same way that local variables are declared.

Module Test
  Dim x As Integer
  Dim y As Long = 5
  Dim z(5) As Integer
End Module

Instance fields live as long as the class or structure that contains them lives, while shared fields live for the length of the program's execution. Fields declared in modules ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required