July 2015
Intermediate to advanced
1300 pages
87h 27m
English
The Common Language Specification (CLS) has established specific rules for structures. If you want your structure to be CLS-compliant, you need to overload the equality and inequality operators and redefine the behavior of the Equals and GetHashCode methods inherited from Object. Listing 11.1 shows an example of a CLS-compliant structure.
LISTING 11.1 Building a CLS-Compliant Structure
<CLSCompliant(True)>Public Structure CLSCompliantStructure Public Shared Operator =( obj1 As CLSCompliantStructure, obj2 As CLSCompliantStructure) As Boolean Return obj1.Equals(obj2) End Operator Public Shared Operator <>( obj1 As CLSCompliantStructure, ...
Read now
Unlock full access