Nested Classes
You can organize classes within other classes. The following code snippet shows how you can define a nested class:
Public Class Test Friend Class NestedClass End ClassEnd Class
Nested classes can also be marked as Private
, and this is the only situation in which the qualifier is enabled. If you make a class private, you cannot use that class outside the class that defines it. Continuing with the preceding example, if the NestedClass
class were marked as Private
, you could use it only within the Test
class. If a nested class is not private, you can invoke it the usual way; you need to write the full name of the class as follows:
Dim nc As New Test.NestedClass
Typically, ...
Get Visual Basic 2015 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.