It wasn't possible before because traditional extension methods rely on an instance of a class.
**C# 14** changes this:
> C# 14 adds new syntax to define extension members. The new syntax enables you to declare extension properties in addition to extension methods. **You can also declare extension members that extend the type, rather than an instance of the type**. **In other words, these new extension members can appear as static members of the type you extend.**
<https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#extension-members>
**Example:**
```
public static class FileExtension
{
extension(File)
{
public static void SayHello(string fileName)
{
Console.WriteLine($"Hello: {fileName}");
}
}
}
```
**Usage:**
```c#
File.SayHello("Introduction.pdf");
```
It wasn't possible before because traditional extension methods rely on an instance of a class.
**C# 14** changes this:
> C# 14 adds new syntax to define extension members. The new syntax enables you to declare extension properties in addition to extension methods. **You can also declare extension members that extend the type, rather than an instance of the type**. **In other words, these new extension members can appear as static members of the type you extend.**
https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#extension-members
**Example:**
```
public static class FileExtension
{
extension(File)
{
public static void SayHello(string fileName)
{
Console.WriteLine($"Hello: {fileName}");
}
}
}
```
**Usage:**
```c#
File.SayHello("Introduction.pdf");
```