473,396 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Collection Class contains

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
2 1504
"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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: S. Justin Gengo | last post by:
Hi, I've created a component that allows me to store database information for various types of databases my company uses. It uses a collection for each type of database. Everything is working...
0
by: Jordan Bowness | last post by:
I make a similar post in another newsgroup, but this example is simplified somewhat. I have a component (cmpMyComponent) with 2 properties. The 1st property is a string value (Description) and...
2
by: jmhmaine | last post by:
I've created a lookup class for a windows form application and I'm stuck on how on using the collection object. The process is simple, if the item is in the collection then return that object, if...
4
by: Michael | last post by:
Dear all .. If I want to use develop a user control and declare a public property which the type is System.Windows.Forms.GridTableStylesCollection For example : Public Class LookAndView...
9
by: Michael D. Ober | last post by:
In the code below, the IComparator function is never called. What am I missing? Public Class ArchiveInfo Implements System.IComparable(Of ArchiveInfo) Public FullName As String = "" Public...
3
by: Dave | last post by:
Please - anyone that can help. I am getting confusing results while trying to expose a collection from a web service. I have a webservice in which a web method accepts a collection as a...
1
by: sdunkerson | last post by:
I think this will be a good one for anyone who fancies themselves a wiz with manipulating data structure in vb.net. Imagine a Dictionary collection of Object "A". One of the properties of Object...
2
by: BSamp | last post by:
I have the following business entity classes shown below. I have a data layer that retrieves the data from the database and populates a new instance of the PendingRecord class then adds it to the...
4
by: Rohan | last post by:
I need to use the Collection editor of the propertyGrid, but i can't this to work, i looked around on the NET on collection and I am kinda lost. i have this so far, i don't know what i should do...
8
by: Tanzen | last post by:
I'm working in visual studio 2005 trying to learn visual basic. Having come from an VB for Access background, I'm finding it a big learning curve. I have been working through several e-books which...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.