i meant to ask how do i manage this internally?
right now i a DIctionary which saves a key as a string, and it's index
in the value part.
so if i want to retrieve the name by the index i do this:
public string this[int index]
{
get
{
foreach (KeyValuePair<string, int> kvp in fields)
{
if (kvp.Value == index)
return kvp.Key;
}
throw new KeyNotFoundException("Key not Found according
To Index " + index);
}
}
Nicholas Paldino [.NET/C# MVP] wrote:
> Elhanan,
>
> No, you just have to put two indexers on your object that is exposed:
>
> public class MyCollection
> {
> public this[int index]
> {
> get
> {
>
> }
> set
> {
>
> }
> }
>
> public this[string index]
> {
> get
> {
>
> }
> set
> {
>
> }
> }
> }
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - (E-Mail Removed)
> "Elhanan" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > hi..
> >
> > i would like to create something very much like DataTable, only for it
> > to hold actuall objects (not their string representation)
> >
> > i saw that DataTable as DataColumn Collection which has to 2 indexes,
> > it can bring up a columns by name or by it's ordinal number, is there
> > any easy way to do this, or do i need to 2 collection objects (an array
> > list and a Dictionary) that will hold both references
> >