(This feature is available starting in .NET 10)
An old-style extension function can be seamlessly converted to a new style extension member, as follow:
// Before
public static int GetLength(this string s)
{
ArgumentNullException.ThrowIfNull(s);
return s.Length;
}
// After
extension(string s)
{
public int GetLength()
{
ArgumentNullException.ThrowIfNull(s);
return s.Length;
}
}public static int GetLength(this string s) // CSL1013: Change 'GetLength' to an extension member.
{
ArgumentNullException.ThrowIfNull(s);
return s.Length;
}