C#C
C#7mo ago
dylanpdx

Can't use C# 11 feature on C# 12

I feel like I'm going crazy with this issue

I'm trying to use a feature that was added in C# 11 (static virtual members in interfaces) and my project targets .NET 9.0, so it should be on C#12, but I'm still getting a CS8926 error. If I manually set my target framework to .NET 7.0 (which is C# 11), it works! If I manually specify <LangVersion>11.0</LangVersion> it also works, but specifying 12.0 causes the error again.

Are features from C#11 not usable in C#12+? I feel like they should

For reference, this is my code:

public interface FileUtils<Output>
{
    public static Output LoadFile(string filePath) => LoadFile(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)); // CS8926 on LoadFile
    public abstract static Output LoadFile(Stream fileData);
}


Thanks in advance
Was this page helpful?