Q: Can we initlize more then one arrays through one indexer in c sharp OR can we initlize multiple arrays thourgh multiple indexers in c# ?
i am trying this code :
public class Name
{
public string[] name = new string[4];
public string this[int index]
{
get
{
return name[index];
}
set
{
name[index] = value;
}
}
public int[] intArray = new int[4];
public int this[int index]
{
get
{
return intArray[Convert.ToInt32(i)];
}
set
{
intArray[Convert.ToInt32(i)] = value;
}
}
} Reply Soon
Thanks.
VulpesPosted Jun 22, 2011, 6:38 AM
Although you can overload indexers with different parameter numbers and/or types (we had a thread about this yesterday), I don't think this will help if you're trying to index multiple single dimensional arrays.
I'd just use the indexer for one of them (the name) and use an ordinary method for the other.