foreach loop from multiple arrays c#

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-06-01T14:10:21Z Indexed on 2010/06/01 14:13 UTC
Read the original article Hit count: 319

Filed under:
|
|

This should be a simple question. All I want to know is if there is a better way of coding this. I want to do a foreach loop for every array, without having to redeclare the foreach loop. Is there a way c# projects this? I was thinking of putting this in a Collection...?

Please, critique my code.

        foreach (TextBox tb in vert)
        {
            if (tb.Text == box.Text)                
                conflicts.Add(tb);                
        }
        foreach (TextBox tb in hort)
        {
            if (tb.Text == box.Text)                
                conflicts.Add(tb);                
        }
        foreach (TextBox tb in cube)
        {
            if (tb.Text == box.Text)
                conflicts.Add(tb);                
        }

© Stack Overflow or respective owner

Related posts about c#

Related posts about arrays