Hi, I have a sorted (alphanumeric) ArrayList of class objects as follows.
In my main class I add each object to an ArrayList collection.
After the collection is complete I sorted it using an AlphaNumeric sorter that implements IComparer, I have now a new Val object like Val.ID = "hello"; How do I search the sorted collection for this value?
Can I use this --> rpt.rptCollecti on.BinarySearch (object, IComparer);??
I just don't know how to implement the IComparer part for this case
Thanks for any help,
Code:
public class reports
{
public System.Collections.ArrayList rptCollection = new System.Collections.ArrayList();
public reports()
{
}
}
public class values
{
private string ID= string.Empty;
private string Num= string.Empty;
private string Inp= string.Empty;
public values()
{
}
public string ID
{
get { return this.ID; }
set { this.id= value; }
}
public string num
{
get { return this.Num; }
set { this.Num= value; }
}
public string inp
{
get { return this.Inp; }
set { this.Inp = value; }
}
}
Code:
namespace whatever
{
class Program
{
static void Main(string[] args)
{
reports rpt = new reports();
while(true){ //keep filling the arrayList with objects until break
values Val = new values();
Val.id = "something";
Val.num = "whatever";
Val.inp = "other";
rpt.rptCollection.Add(Val);
if(something){
break;
}
}
}
}
}
Can I use this --> rpt.rptCollecti on.BinarySearch (object, IComparer);??
I just don't know how to implement the IComparer part for this case
Thanks for any help,
Comment