I would appreciate any help that can be given. I'm new to c# and mostly develop in c++. I'm using Microsoft Visual Studio 2010 as my IDE. My question is I'd like to ouput cars from a car collection. I'm using a 3rd party DLL library. As far as I know the dll has 2 classes for to reference. They are CarCollection and Car.
CarCollection has the following functions:
|
Car.cs:
|
All I'm trying to do is output each Car's name and ID which is in the dll. For now, I'm using a simple main class. I have no idea how to iterate through the CarCollection since it's not an array or actual collection. I'm doing CarCollection aCollection = new CarCollection(); When I use aCollection.FindByName() I get a message which does not help. After that I'm stumped. I know I have to use public IEnumerable<Car> FindByName(string name); from the CarCollection class but I have no idea how. I wish they passed the collection as an array because then I can do a simple for loop like
for(int i = 0; i
{
collection(i).getName();
}
something like that, but I guess thats not the case. Please I would appreciate any help. Thanks.
-Adrian
Jaish MathewsPosted Apr 12, 2010, 1:43 PM
Just tell CarCollection class has any base class like Collectionbase or IEnumerable etc..
Also have u permission to modify this class or need to use as like?
Sam HobbsPosted Apr 12, 2010, 1:40 PM
Why do you say you "have to use public IEnumerable
In order to help you, we need to see the documentation of the component. Better yet, you should look at the documentation some more.
Jaish MathewsPosted Apr 12, 2010, 5:13 AM
foreach(Car carObj in CarCollection)
{
//carObj.ID, carObj.Name etc....
}