0

I have two enum classes

public enum ENUM1
{
   value1 = 1,
   value2 = 2,
   value3 = 3
}

public enum ENUM2
{
    event1 = 1,
    event2 = 2,
    event3 = 3  
}

Then I have a class that combines two of those

public class EnumCombo
{
    private ENUM2 _e2;
    private ENUM1 _e1;

    public ENUM1 e1
    {
        get { return _e1; }
        set { _e1 = value; }
    }

    public ENUM2 e2
    {
        get { return _e2; }
        set { _e2 = value; }
    }
}

And finally a list

private List<EnumCombo> _ec = new List<EnumCombo>();
public List<EnumCombo> ec
{
    get { return _ec; }
    set { _ec = value; }
}

How can I check if ENUM1 from the list is set to the value1?

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • 5
    Aside from anything else, now would be a good time to learn about automatically implemented properties and .NET naming conventions. Next, it sounds like you could really benefit from LINQ... when you say "if ENUM1 from the list is set to the value1" do you mean "Check whether *any* element of the list has a value of `value1` for its `e1` property"? (A [mcve] demonstrating the problem with sample data would be helpful...) – Jon Skeet Sep 19 '16 at 10:26
  • Welcome to programming in general and Stack Overflow in specific. The way you asked this question is not the way we'd like to see things here. See the [tour] and [ask] page. What is missing from your question is an accurate description of what **exactly** you're trying to do, and the things you tried to get that code to do what you want it to. See [Find element in List<> that contains value](http://stackoverflow.com/questions/16177225/find-element-in-list-that-contains-value), which I'm pretty sure answers your question. – CodeCaster Sep 19 '16 at 10:28
  • I'm so sorry. Just wanted to get answer as soon as possible and I didn't find any questions here that are similar to mine. Gonna discover it by myself. – WingedHarbinger Sep 20 '16 at 08:19

0 Answers0