C
C#2w ago
zacoons

✅ C# 14 extension indexers?

There are extension properties and extension statics, but is it possible to write extension indexers? I've tried the following, but it says "this member is not allowed in an extension block".
extension(DataGridViewRow row)
{
public DataGridViewCell this[int i] => row.Cells[i];
}
extension(DataGridViewRow row)
{
public DataGridViewCell this[int i] => row.Cells[i];
}
2 Replies
leowest
leowest2w ago
GitHub
CS9282: This member is not allowed in an extension block · Issue #...
Version Used: .NET 10 RC 1 Steps to Reproduce: Attempt to compile the extension indexer example from the documentation: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#extension...
zacoons
zacoonsOP2w ago
Oh, bummer

Did you find this page helpful?