c# – Extension properties in C #


Is it possible to make an extension property for a class? For example, I have an extension method like this:

public static class StringExtension
    public static string Normalize(this string str)
        return str.Trim().ToUpper();

It is used like this: user.NormalizedName = user.Name.Normalize();

I want to use it like this: user.NormalizedName = user.Name.Normalized;


No, properties as extensions in C # are not supported, perhaps in future versions they will be, discussions about this are underway. At the moment, only methods can be extensions.

Scroll to Top