Spen D
Spen D

Reputation: 4345

how to search a string in structure variable ( C# )

 public struct Items
{
    public string Id;
    public string Name;

}

   public Items[] _items = null;

if (_items.Contains("Table"))
                {
                    // i need to check the structure and need to return correponding id
                }

and am having a list of variables in my structure variable...
i need to search a Name in the structure(_items) and i want to return the Corresponding Id.

how to do this,

Upvotes: 0

Views: 1123

Answers (1)

Svisstack
Svisstack

Reputation: 16616

foreach (Items item in _items)
{
    if (item.Name.Contains("search string"))
    {
        return item.Id;
    }
}

Upvotes: 1

Related Questions