---
title: "Total number of items defined in an enum C#"  
description: "Total number of items defined in an enum C#"  
author: "Anonymous User"  
published: 2018-04-02  
updated: 2018-04-02  
canonical: https://www.mindstick.com/forum/34453/total-number-of-items-defined-in-an-enum-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Total number of items defined in an enum C#

I want to [count](https://www.mindstick.com/forum/157774/selecting-count-with-distinct) the number. How can I get the number of [items](https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios) defined in an [enum](https://www.mindstick.com/forum/159626/how-can-i-cast-a-string-to-an-enum)?

```
enum MyEnum
{
    A = 1,
    B = 2,
    C = 1,
    D = 3,
    E = 2
}
```

## Replies

### Reply by Anonymous User

For this You can use the static method Enum.GetNames \

var myEnumMemberCount = Enum.GetNames(typeof(MyEnum)).Length;


---

Original Source: https://www.mindstick.com/forum/34453/total-number-of-items-defined-in-an-enum-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
