Writing CLS-Compliant Code in C#
The syntax of C# ensures that many CLS rules can’t be broken. For example, C# doesn’t permit the declaration of global static fields or non-zero-based arrays, both requirements of CLS compliance. However, some CLS rules can’t be enforced by the language, and guaranteeing that they’re followed is the responsibility of the programmer. The following list highlights some key requirements of writing CLS-compliant code in C#:
Case must not be used to differentiate between program element identifiers such as member names.
All member parameter and return types must be CLS-compliant; this means the following simple types cannot be used: sbyte, ushort, uint, and ulong.
Pointer types and function pointers aren’t CLS-compliant. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access