C
craig
I am using an ArrayList named "nodeRanks" of the following structs:
private struct NodeRank
{
public TreeNode Node;
public Int32 Rank;
}
I sort the nodeRanks ArrayList based upon the rank values, and then I would
like to replace the rank values with the ArrayList index values. However,
when I try the following approach, I get a runtime error:
for(int i=0;i<=nodeRank.Count-1;i++)
{
((NodeRank)nodeRanks).rank = i;
}
The error that I get is: (3696): The left-hand side of an assignment must
be a variable, property or indexer
I am not sure why I am getting this error because the left side of my
assignment is a public field (variable) of the struct. If I re-write the
code as follows, it works. But I would still like to know why the more
consise syntax fails.
NodeRank tempNodeRank;
for(int i=0;i<=nodeRank.Count-1;i++)
{
tempNodeRank = (NodeRank)nodeRanks;
tempNodeRank.rank = i;
nodeRanks = tempNodeRank;
}
Thanks!!
private struct NodeRank
{
public TreeNode Node;
public Int32 Rank;
}
I sort the nodeRanks ArrayList based upon the rank values, and then I would
like to replace the rank values with the ArrayList index values. However,
when I try the following approach, I get a runtime error:
for(int i=0;i<=nodeRank.Count-1;i++)
{
((NodeRank)nodeRanks).rank = i;
}
The error that I get is: (3696): The left-hand side of an assignment must
be a variable, property or indexer
I am not sure why I am getting this error because the left side of my
assignment is a public field (variable) of the struct. If I re-write the
code as follows, it works. But I would still like to know why the more
consise syntax fails.
NodeRank tempNodeRank;
for(int i=0;i<=nodeRank.Count-1;i++)
{
tempNodeRank = (NodeRank)nodeRanks;
tempNodeRank.rank = i;
nodeRanks = tempNodeRank;
}
Thanks!!