Indexer does not show

  • Thread starter Thread starter Vera
  • Start date Start date
V

Vera

Hi,

I built a user control myPanel derived from the Panel
class.
In myPanel I added code for an indexer which looks like
this:

private Color[] mColor = new Color[10];
[IndexerName("Colors")]
public Color this [int i]
{
get
{
if (i < 0 || i >= 10)
return Color.Empty;
else
return mColor;
}
set
{
if (i < 0 || i >= 10)
// Do nothing
else
{
mColor = value;
}
}
}

I also added some properties that are not indexed.

When I add myPanel to a form, I see all the properties
that I added in the property window, but I don't see the
indexer.

What did I do wrong?
Can anybody help me with this, please?

Thanx a lot!

Vera
 
If you are looking for the indexer in the Intellisense list, you probably
will not see it. The indexer in C# is not handed by a direct call to a
property but rather the index notation ([...]). The name that you gave it,
I believe, is for languages that do not support the index notation such as
VB.
 
Back
Top