MattWoberts
Programmer
Hi, I have created a collection class derived from CollectionBase, which holds a collection of simple structures.
It works nicely, but when I want to change the value of one of the entities in the collection, I expected the following code to work:
coll[0].x = 10;
But I get this error:
Cannot modify the return value of 'XXX.CollClass.this[int]' because it is not a variable.
Can anybody point me in the right direction? Ta!
---------------------
Code for the collection:
public class CollClass: CollectionBase
{
//strongly typed accessor
public EntityClass this[int index]
{
get
{
return (EntityClass ) this.List[index];
}
set
{
this.List[index] = value;
}
}
public void Add(EntityClass perfGraphDataEnt)
{
this.List.Add(perfGraphDataEnt);
}
}
It works nicely, but when I want to change the value of one of the entities in the collection, I expected the following code to work:
coll[0].x = 10;
But I get this error:
Cannot modify the return value of 'XXX.CollClass.this[int]' because it is not a variable.
Can anybody point me in the right direction? Ta!
---------------------
Code for the collection:
public class CollClass: CollectionBase
{
//strongly typed accessor
public EntityClass this[int index]
{
get
{
return (EntityClass ) this.List[index];
}
set
{
this.List[index] = value;
}
}
public void Add(EntityClass perfGraphDataEnt)
{
this.List.Add(perfGraphDataEnt);
}
}