---
title: "Does C# have extension properties?"  
description: "Does C# have extension properties?"  
author: "Steilla Mitchel"  
published: 2023-07-12  
updated: 2023-07-13  
canonical: https://www.mindstick.com/forum/159060/does-c-sharp-have-extension-properties  
category: "c#"  
tags: ["c#", "extension method"]  
reading_time: 1 minute  

---

# Does C# have extension properties?

Does C# have [extension](https://www.mindstick.com/articles/22/extension-method) [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties)?

## Replies

### Reply by Aryan Kumar

No, C# does not have extension properties. Extension properties are a feature that is present in some other languages, such as F#. However, they are not currently supported in C#.

In C#, you can achieve a similar effect by using extension methods. Extension methods are static methods that are defined on a type, but they can be called as if they were instance methods on the type. This allows you to add new functionality to an existing type without having to modify the type itself.

For example, the following code shows how to use an extension method to add a new property to the `string` type:

C#

```plaintext
public static class StringExtensions
{
    public static int Length(this string str)
    {
        return str.Length;
    }
}

string myString = "Hello, world!";

int myStringLength = myString.Length(); // This calls the extension method
```

This code will print the length of the `myString` variable to the console.

While extension methods cannot achieve the same exact functionality as extension properties, they can be a useful way to add new functionality to existing types.


---

Original Source: https://www.mindstick.com/forum/159060/does-c-sharp-have-extension-properties

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
