Rules About Classes

The CLS influences classes’ implementation with basically a few rules. The most rules are related to inheritance as much is for methods. Because inheritance hasn’t been covered yet (discussed in Chapter 12, “Inheritance”), the only rule mentioned here is that if a class exposes only shared members, it must have an empty private constructor and must be marked as NotInheritable, as follows:

<CLSCompliant(True)> Public NotInheritable Class GzipCompress    'Empty private constructor    Private Sub New()    End Sub    Public Shared Sub Compress(ByVal fileName As String,            ByVal target As String)    End Sub    Public Shared Sub Decompress(ByVal fileName As String,            ByVal source As ...

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.