Skip to content

Typo in field's CLS compliance example #49691

@es1-gar

Description

@es1-gar

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-compliant

In 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

@gewarren

Metadata

  • ID: f7fc5e5d-162e-61e2-6348-3515c5e0ad0f
  • PlatformId: 67a109f7-0a4f-b6fb-d59e-a37a442e1b30
  • Service: dotnet-fundamentals

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⌚ Not TriagedNot triageddoc-bugdotnet-fundamentals/svcgood first issueIssue should be good for first-time contributors, with clear instructionshelp wantedGood for community contributors to help [up-for-grabs]okr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions