i want to create an int indexer...this is the code:
public class Ctest
{
public Ctest(int len)
{
i=len;
}
public int this[int i2]
{
get {return i;}
set {i=value;}
}
private int i;
}
public void main()
{
Ctest tt= new Ctest(5);
}
the problem is..that its aint really creatin an array....when i assign a value to a specific index in the indexer...it applies it to all the indexer(array) for e.g:
tt[0]=10;
if ill do this:
Console.Writeline(tt[1].tostring());
it would produce the same value that is in tt[0].
any idea???
(im pretty new with indexes)
public class Ctest
{
public Ctest(int len)
{
i=len;
}
public int this[int i2]
{
get {return i;}
set {i=value;}
}
private int i;
}
public void main()
{
Ctest tt= new Ctest(5);
}
the problem is..that its aint really creatin an array....when i assign a value to a specific index in the indexer...it applies it to all the indexer(array) for e.g:
tt[0]=10;
if ill do this:
Console.Writeline(tt[1].tostring());
it would produce the same value that is in tt[0].
any idea???
(im pretty new with indexes)