Top
image credit: Adobe Stock

C# 11 and .NET 7 Bring Generic Parsing

November 17, 2022

Via: InfoQ

One of the basic design patterns in .NET is the static Parse function. Virtually every class that can be instantiated from a string representation has one. Yet before C# 11 and .NET 7, there was no way to create an interface that accommodated this.

The fundamental problem is before now, abstract interfaces (i.e. the interface keyword) didn’t support static functions. This wasn’t just a C# limitation, the CLR itself didn’t support it before the introduction of the Static Abstract Methods in interfaces feature.

As with interface methods, Static Abstract Methods can have a default implementation, but there are limitations.

Read More on InfoQ