# What's new in C# 15: Two features for library authors

The last two C# 15 features matter most to people who write libraries and low-level code. Here's what they are, in plain words, so you know them when you meet them.

By Gregor Dzierzon · Published November 17, 2026

![Codey stands in a library aisle where the shelves hold neatly labeled software packages instead of books](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/71e0023d68b04553af32f7845ffd7430.webp)

> **What's new in C# 15**
>
> 1. [The release: .NET 11, LTS and STS](https://www.ask-codey.com/blog/whats-new-in-csharp-15)
> 2. [Union types](https://www.ask-codey.com/blog/whats-new-in-csharp-15-union-types)
> 3. [Labeled `break` and `continue`](https://www.ask-codey.com/blog/whats-new-in-csharp-15-labeled-break-and-continue)
> 4. [Closed hierarchies](https://www.ask-codey.com/blog/whats-new-in-csharp-15-closed-hierarchies)
> 5. [Collection expression arguments](https://www.ask-codey.com/blog/whats-new-in-csharp-15-collection-expression-arguments)
> 6. [Extension indexers](https://www.ask-codey.com/blog/whats-new-in-csharp-15-extension-indexers)
> 7. **For library authors: static interface members on older runtimes, and memory safety**
>
> [All posts in this series](https://www.ask-codey.com/blog?tag=csharp-15)

## For library authors

The last two features in C# 15 aren't ones most of us will type every day. They matter to people who write **libraries**, code that other programs download and use, and to people who write low-level code that works directly with memory. You'll still meet them in other people's code, so here's what each one is for.

### Static interface members on older runtimes

![An interface drawn as a clipboard labeled IMeasurement, with a ToMeters helper tool clipped to it, plugs into a new computer labeled .NET 11 and an older one labeled .NET Standard 2.0, both with green checks; Codey points](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/510446a1d3cc4a89a844dc7b90da3534.webp)

An **interface** is a promise: "anything that implements me has these members." Sometimes a helper method belongs with that promise, so you put a **static** method on the interface itself and call it through the interface's name:

```csharp
public interface IMeasurement
{
    public static double ToMeters(double centimeters) => centimeters / 100;
}
```

```csharp
double meters = IMeasurement.ToMeters(250);   // 2.5
```

**The problem:** many libraries are built for older targets too, such as .NET Standard 2.0, so that apps on the older .NET Framework can still use them. Until now, the compiler refused a helper like this when building for those targets. Build this interface for .NET Standard 2.0 with C# 14, and it fails with error CS9327, "Feature 'static members in interfaces' is not available in C# 14.0."

**The C# 15 answer:** a plain (non-virtual) static member on an interface now works [even when the target runtime doesn't support default interface implementations](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface). The same code builds for .NET Standard 2.0 with C# 15. The helper can live where it belongs, on the interface, without leaving older apps behind.

It's a narrow change. Other interface features that need help from the runtime, such as default implementations of instance methods and `static abstract` members, still need a newer runtime.

### Memory safety (a preview)

Most C# code never touches memory directly: .NET manages it for you. But for speed, or to talk to code written in other languages, C# lets you use **pointers**, variables that hold a memory address. Pointers are powerful and easy to get wrong, so C# makes you mark that code with the word **`unsafe`**, as a warning sign to every reader.

**The problem:** today, the sign goes up for anything that *mentions* a pointer, even lines that can't hurt anything. Declaring a pointer, or taking the address of a variable, needs `unsafe` just as much as reading the memory it points to does. When everything is marked dangerous, the sign stops meaning much.

**The C# 15 preview:** it starts to [tie `unsafe` to the operations that actually access memory](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/unsafe-code), not to the mere mention of a pointer:

```csharp
int number = 42;
int* pointer = &number;   // no longer needs unsafe: nothing is read or written yet

unsafe
{
    Console.WriteLine(*pointer);   // reading through the pointer still does
}
```

![Two panels: in Today, a warning sign stands beside every line that mentions a pointer; in Preview, a warning sign stands only beside the line that reads memory; Codey with a magnifying glass says a warning sign on everything is a warning sign on nothing](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/2cb28f511f084bb18e08e7bb1673ea63.webp)

The preview also makes `unsafe` on a method a **contract**: whoever calls that method has to be in an `unsafe` block too, so the warning sign travels with the danger instead of hiding inside the method.

This is a preview, so it's off unless you switch it on. In the project file:

```xml
<PropertyGroup>
  <LangVersion>preview</LangVersion>
  <Features>$(Features);updated-memory-safety-rules</Features>
  <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
```

Microsoft calls it the start of ["a multirelease effort to redefine memory safety in the language"](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-15), so expect it to change before it's final. If you don't write `unsafe` code today, you can safely ignore it. If you do, it's worth trying on a branch and telling the .NET team what you find.

That's all seven C# 15 features. The big ones for everyday code are union types and closed hierarchies; the rest make common code a little shorter and a little safer.

**On one page:** [the library authors cheat sheet](https://www.ask-codey.com/cheat-sheets/csharp-15-for-library-authors-cheat-sheet), to keep or to share.

## Sources

- Microsoft, [What's new in C# 15](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-15), Microsoft Learn: both features, and memory safety's multirelease plan.
- Microsoft, [Interfaces (C# reference)](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface), Microsoft Learn: static interface members on older runtimes, and what still needs a newer runtime.
- Microsoft, [Unsafe code, pointer types, and function pointers](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/unsafe-code), Microsoft Learn: the updated memory safety rules.
- Microsoft, [Language version (C# compiler options)](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/language), Microsoft Learn: switching on the memory safety preview.

Tags: [csharp](https://www.ask-codey.com/blog?tag=csharp), [csharp-15](https://www.ask-codey.com/blog?tag=csharp-15), [dotnet](https://www.ask-codey.com/blog?tag=dotnet), [whats-new](https://www.ask-codey.com/blog?tag=whats-new)

## Glossary subjects

- [C#](https://www.ask-codey.com/glossary/subjects/c-sharp)

## More posts

- Previous: [What's new in C# 15: Extension indexers](https://www.ask-codey.com/blog/whats-new-in-csharp-15-extension-indexers)
- Next: [Vibe coding vs. software engineering with AI](https://www.ask-codey.com/blog/vibe-coding-vs-software-engineering-with-ai)

Source: https://www.ask-codey.com/blog/whats-new-in-csharp-15-for-library-authors
