Type of issue
Other (describe below)
Description
In this example:
The preceding sample can also be created using extension blocks in C# 14:
C#
public static class AccountExtensions
{
extension(ref Account account)
{
// ref keyword can also appear before the this keyword
public void Deposit(float amount)
{
account.balance += amount;
// The following line results in an error as an extension
// method is not allowed to access private members
// account.secret = 1; // CS0122
}
}
}
The comment // ref keyword can also appear before the this keyword is obsolete as this keyword is not used in this example.
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/extension-methods.md
Document Version Independent Id
50c65125-3700-c713-ede0-2204e09eb307
Platform Id
ab28cf81-498c-852f-aa74-4aac99b9239c
Article author
@BillWagner
Metadata
- ID: 2a5e0b56-4d67-b219-46fa-d837045e6612
- PlatformId: ab28cf81-498c-852f-aa74-4aac99b9239c
- Service: dotnet-csharp
- Sub-service: fundamentals
Related Issues
Associated WorkItem - 599252
Type of issue
Other (describe below)
Description
In this example:
The comment
// ref keyword can also appear before the this keywordis obsolete asthiskeyword is not used in this example.Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/extension-methods.md
Document Version Independent Id
50c65125-3700-c713-ede0-2204e09eb307
Platform Id
ab28cf81-498c-852f-aa74-4aac99b9239c
Article author
@BillWagner
Metadata
Related Issues
Associated WorkItem - 599252