Home   Cover Cover Cover Cover
 

Attribute CLSCompliant

Question: Consider the following code fragments (see book) and decide which classes, methods and fields are checked for CLS compliance by the C# compiler (the compiler will not report an error in any of these cases). Give a short justification of your answers?

Answer: see 3.3.1 Attribute CLSCompliant

class A: CLS compliance is not checked at all, because this is not explicitly demanded

class B: CLS compliance is checked for all elements of the assembly, because this is demanded for the entire assembly and all elements are public

class C: CLS compliance is checked for class C and the field F1, but not for the method M1, because it is private and thus the CLS rules do not apply (sbyte would not be CLS compliant).