By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,961 Members | 2,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,961 IT Pros & Developers. It's quick & easy.

Collection Class contains

P: n/a
Jon
Hello all.

I have a collection class that holds a number of clauses. One particular
type of clause has a member variable called type - this is an enum.

How do I check this collection class to see if it has a clause of a
particular type?

I know I'll have to implement a contains (or similar) method, but I'm after
code examples.

Thanks in advance.

Jon
Sep 29 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Jon" <Jo*@discussions.microsoft.coma écrit dans le message de news:
C1**********************************@microsoft.com...

| I have a collection class that holds a number of clauses. One particular
| type of clause has a member variable called type - this is an enum.
|
| How do I check this collection class to see if it has a clause of a
| particular type?
|
| I know I'll have to implement a contains (or similar) method, but I'm
after
| code examples.

If you are using .NET 2.0 generic collections :

bool NameMatch(MyType value)
{
return value.Name == "Joanna";
}

void Test()
{
List<MyTypeitems = new List<MyType>();

// add items to list

MyType found = items.Find(NameMatch);

...
}

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Sep 29 '06 #2

P: n/a

Here I have an object called "Order"
It has an (int) property called "OrderID"

I passed in an orderId to try and find a match.
public Order Contains( int orderId )
{

foreach( Order item in base.InnerList )
if( item.OrderID .Equals(orderId) )
{
return item;
}
return null;

}




"Jon" <Jo*@discussions.microsoft.comwrote in message
news:C1**********************************@microsof t.com...
Hello all.

I have a collection class that holds a number of clauses. One particular
type of clause has a member variable called type - this is an enum.

How do I check this collection class to see if it has a clause of a
particular type?

I know I'll have to implement a contains (or similar) method, but I'm
after
code examples.

Thanks in advance.

Jon

Sep 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.