how to use "indexof" with an user define struct array

  • Thread starter Thread starter Herve MAILLARD
  • Start date Start date
H

Herve MAILLARD

Hi,

Hi have the following array

public struct Type_Var
{
public int ID;
public string Mnemonique;
public DateTime Date;
public float Valeur;
public bool Archived;
public short Invalid;
}
public Type_Var[] Var_Data;

I need to use Var_Data.indexof("ABCDE");

I want to search only in the Mnemonique field.

How can I do that ?

thanks for your help.

H. MAILLARD
 
class Type_VarCollection : CollectionBase {
public Type_Var this[string index] {
get {
foreach (Type_Var v in ((IList)this).Items)
if (v.Mnemonique == index) return v;
}
}
}

You may have to fool around with ((IList)this).Items, but that's the general
idea. Then instead of declaring

Type_Var[] Var_Data;

you would declare

Type_VarCollection Var_Data;

Chris
 
Back
Top