Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Get enum values based on attribute

$
0
0

I have an enum. I'm binding values to the combo. But I should get the values based on an attribute as below? How can I do this?

combo1.DataSource = Enum.GetValues(typeof(AnimalType)).Where(Attribute["IsWild"] = true);


public class AnimalEnum : XmlEnumAttribute

{ public bool IsWild { set; get; } } public enum AnilmalType { [AnimalEnum(Name = "Dog", IsWild = false)] Dog, [AnimalEnum(Name = "Cat", IsWild = false)] Cat, [AnimalEnum(Name = "Tiger", IsWild = true)] Tiger, [AnimalEnum(Name = "Lion", IsWild = true)] Lion }


Your help is greatly appreciated.


Sunil


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>