Indexer in C sharp.
Posted
by Jacksquad
on Stack Overflow
See other posts from Stack Overflow
or by Jacksquad
Published on 2010-05-26T07:16:49Z
Indexed on
2010/05/26
7:21 UTC
Read the original article
Hit count: 294
c#3.0
Hello guys, i got a problem while overloading indexer property.
public class ClassName
{
private int[] a;
private int[] b;
private string[] c;
private string[] d;
public int this[int pos]
{
get{ return a[pos];}
set{a[pos] = value;}
}
public int this[int pos]
{
get{ return b[pos];}
set{b[pos] = value;}
}
public int this[int pos]
{
get{ return c[pos];}
set{c[pos] = value;}
}
public int this[int pos]
{
get{ return d[pos];}
set{d[pos] = value;}
}
}
/* I AM GETTING "Error 1 'Class1 variables' already defines a member called 'this' with the same parameter types"
Please suggest me how to implement this?
© Stack Overflow or respective owner