Click here to Skip to main content
15,895,462 members
Home / Discussions / C#
   

C#

 
GeneralDataGrid full row select Pin
Guinness4Strength23-Apr-04 4:18
Guinness4Strength23-Apr-04 4:18 
GeneralRe: DataGrid full row select Pin
Heath Stewart23-Apr-04 5:13
protectorHeath Stewart23-Apr-04 5:13 
GeneralRe: DataGrid full row select Pin
Jay Shankar25-Apr-04 18:09
Jay Shankar25-Apr-04 18:09 
GeneralRe: DataGrid full row select Pin
Guinness4Strength26-Apr-04 4:18
Guinness4Strength26-Apr-04 4:18 
GeneralRe: DataGrid full row select Pin
Jay Shankar26-Apr-04 14:42
Jay Shankar26-Apr-04 14:42 
GeneralRe: DataGrid full row select Pin
Guinness4Strength27-Apr-04 3:23
Guinness4Strength27-Apr-04 3:23 
GeneralArray.IndexOf with an array of structures Pin
ebbie23-Apr-04 3:29
ebbie23-Apr-04 3:29 
GeneralRe: Array.IndexOf with an array of structures Pin
Heath Stewart23-Apr-04 3:54
protectorHeath Stewart23-Apr-04 3:54 
In this case it'd be better to implement a list or collection (for instance, derive from CollectionBase) and override the indexer or even add your own so that in the get accessor you enumerate your structs stored in the internal ArrayList (the List property inherited from CollectionBase, or your own if you just implement the necessary interfaces like IList, which inherits from ICollection, which inherits from IEnumerable) and find the struct with the name property equal to the value you pass, like so:
public MyStruct this[string name]
{
  get
  {
    if (name == null) throw new ArgumentNullException("name");
    foreach (MyStruct s in List)
      if (string.Compare(s, name) == 0) return s;
    throw new ArgumentException("The structure was not found.", "name");
  }
}
Using just an array of your structs, you won't be able to do what you want unless you implement your own IComparer and call one of the Array.BinarySearch overloads which takes an IComparer implementation as a parameter.

 

Microsoft MVP, Visual C#
My Articles
GeneralAdapter Parameter Pin
DougW4823-Apr-04 0:24
DougW4823-Apr-04 0:24 
GeneralRe: Adapter Parameter Pin
Jon G23-Apr-04 2:06
Jon G23-Apr-04 2:06 
GeneralRe: Adapter Parameter Pin
Heath Stewart23-Apr-04 2:21
protectorHeath Stewart23-Apr-04 2:21 
GeneralRe: Adapter Parameter Pin
Heath Stewart23-Apr-04 2:08
protectorHeath Stewart23-Apr-04 2:08 
GeneralIncluding header file in C# Pin
Aisha Ikram22-Apr-04 23:28
Aisha Ikram22-Apr-04 23:28 
GeneralRe: Including header file in C# Pin
Colin Angus Mackay22-Apr-04 23:40
Colin Angus Mackay22-Apr-04 23:40 
GeneralRe: Including header file in C# Pin
Ian Darling23-Apr-04 0:43
Ian Darling23-Apr-04 0:43 
Generalmatrix determinant in 3*3 d Pin
kcal22-Apr-04 23:26
kcal22-Apr-04 23:26 
GeneralRe: matrix determinant in 3*3 d Pin
Heath Stewart23-Apr-04 2:13
protectorHeath Stewart23-Apr-04 2:13 
GeneralRe: matrix determinant in 3*3 d Pin
Heath Stewart23-Apr-04 2:19
protectorHeath Stewart23-Apr-04 2:19 
GeneralVisio object events detection Pin
narada10822-Apr-04 23:25
narada10822-Apr-04 23:25 
GeneralRe: Visio object events detection Pin
Heath Stewart23-Apr-04 2:29
protectorHeath Stewart23-Apr-04 2:29 
GeneralRe: Visio object events detection Pin
narada10826-Apr-04 0:12
narada10826-Apr-04 0:12 
GeneralRe: Visio object events detection Pin
narada10826-Apr-04 1:22
narada10826-Apr-04 1:22 
GeneralRe: Visio object events detection Pin
Heath Stewart26-Apr-04 3:01
protectorHeath Stewart26-Apr-04 3:01 
GeneralRe: Visio object events detection Pin
Anonymous26-Apr-04 4:35
Anonymous26-Apr-04 4:35 
GeneralRe: Visio object events detection Pin
narada10827-Apr-04 20:22
narada10827-Apr-04 20:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.