Skip to content

The code example doesn't reflect the text description. #50089

@Xulei-NL

Description

@Xulei-NL

Type of issue

Typo

Description

In the Static constructors section, the first example is

public class Adult : Person
{
   private static int minimumAge;

   public Adult(string lastName, string firstName) : base(lastName, firstName)
   { }

   static Adult() => minimumAge = 18;

   // Remaining implementation of Adult class.
}

However based on the context, I think the first example should be the following code since the second example employs the expression body definition.

public class Adult : Person
{
   private static int minimumAge;

   public Adult(string lastName, string firstName) : base(lastName, firstName)
   { }

   static Adult() 
   {
      minimumAge = 18; // Here is the change I propose.
   }

   // Remaining implementation of Adult class.
}

What do you think of it?

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/constructors

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/constructors.md

Document Version Independent Id

7f3cd611-9d80-4523-6ba5-17e1e9ab5c67

Platform Id

b9778cfa-3239-7384-359d-bf5c8714b98b

Article author

@BillWagner

Metadata

  • ID: 754eaea9-3482-4a69-5b65-ebe4a5065597
  • PlatformId: b9778cfa-3239-7384-359d-bf5c8714b98b
  • Service: dotnet-csharp
  • Sub-service: fundamentals

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions