-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Type of issue
Typo
Description
This part of the documentation states that, in an example class Person which contains two members, one private UInt16 personAge and a public UInt16 Age; in order for the class to become CLS Compliant, only the public member needs to be changed to Int16 (CLS Compliant) while the private one does not.
"For example, unsigned integers other than Byte are not CLS-compliant. Because the Person class in the following example exposes an Age property of type UInt16, the following code displays a compiler warning."
using System;
[assembly: CLSCompliant(true)]
public class Person
{
private UInt16 personAge = 0;
public UInt16 Age
{ get { return personAge; } }
}
// The attempt to compile the example displays the following compiler warning:
// Public1.cs(10,18): warning CS3003: Type of 'Person.Age' is not CLS-compliantIn the next code that incorporates this statement, both the private and public members are swapped to the Int16 type causing confusion.
using System;
[assembly: CLSCompliant(true)]
public class Person
{
private **Int16** personAge = 0;
public Int16 Age
{ get { return personAge; } }
}Page URL
https://learn.microsoft.com/en-us/dotnet/standard/language-independence
Content source URL
https://github.com/dotnet/docs/blob/main/docs/standard/language-independence.md
Document Version Independent Id
b671dce5-aebd-a058-d73c-58ea0e502f06
Platform Id
67a109f7-0a4f-b6fb-d59e-a37a442e1b30
Article author
Metadata
- ID: f7fc5e5d-162e-61e2-6348-3515c5e0ad0f
- PlatformId: 67a109f7-0a4f-b6fb-d59e-a37a442e1b30
- Service: dotnet-fundamentals