randy,
There are several solutions to the problem.
1. If you use generic collection such as ArrayList you can create custom
comparer - a class that implment IComparer method and then use the
vendorName for comparing the objects. Once you have this use ArrayList.Sort
overload that accepts comparer object.
2. Using SortedList class. This class is key/value collection and sorts the
elements by the key value. When adding the objects use vendorName as key.
There are of course other possible solutions.
--
HTH
Stoitcho Goutsev (100)
"randy" <ra***@d.comwrote in message
news:uB**************@TK2MSFTNGP03.phx.gbl...
>I need to loop through a collection of objects (see below) based on the
field vendorName. I basically need to sort by vendorID and then pull the
product info from each vendor. There are multiple products per vendor.
Any ideas?
public partial class Product
{
private string productID;
private string productName;
private string vendorID;
private string vendorName;
....
}
Thanks