Defining Nested Classes

A nested class is quite simply a class defined within a class. Nested classes can be defined with all of the elements of any other class. Here's the skeletal code for a nested class:

Public Class Outer
  Public Class Nested
  End Class
End Class

Your motivation for creating nested classes is to collect a group of elements that make sense together and only within the containing class. For example, if you have a class and some fields, properties, and methods that define a concept separate but a part of the containing class and you want to store multiple variations of state, you might implement a nested class.

In general you won't need to implement nested classes. Any implementation that can be done with nested classes can ...

Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.