Typo in field's CLS compliance example
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 370
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](https://learn.microsoft.com/en-us/dotnet/api/system.byte) are not CLS-compliant. Because the Person class in the following example exposes an Age property of type [UInt16](https://learn.microsoft.com/en-us/dotnet/api/system.uint16), the following code displays a compiler warning."
```c#
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-compliant
```
In the next code that incorporates this statement, **both** the private and public members are swapped to the **Int16** type causing confusion.
```c#
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
@gewarren
### Metadata
* ID: f7fc5e5d-162e-61e2-6348-3515c5e0ad0f
* PlatformId: 67a109f7-0a4f-b6fb-d59e-a37a442e1b30
* Service: **dotnet-fundamentals**
[Related Issues](https://github.com/dotnet/docs/issues?q=is%3Aissue+is%3Aopen+b671dce5-aebd-a058-d73c-58ea0e502f06)
Contributor guide
Assessment
This issue has not been assessed yet.