There are only two problems with this translation from VB.
1) you aren't looking for the 10th node (which is what the code looks like
it's trying to do. can you tell by the C# indexer consumer code if you are
trying to get the 10th child vs the 10th sibling, for example?), you're
looking for the 10th Child on a node. The C# indexer can get confusing if
you aren't allowed to specify a non-default name
2) becaue the indexers aren't named in C#, you can't have more than one (you
can only override the default one, but that doesn't allow for certain
property semantics). this is silly, because behind the scenes, C# is in fact
creating a named property in IL, and applying the "default" meta-tag to it.
It wouldn't be too much work to create named properties with arguments that
don't have the "default meta-tag, as VB does.
However the above two issues are more along the lines of theory with regards
to the absense of named parameters with arguments - a better way to solve
the actual problem in this particular example as you have presented it
(which works fine in C#) is to create a readonly Child property on the node,
which is of type Nodes (a collection of Node), and have an indexer on *it*.
That allows you to use:
myNode.Child[10]
instead of
myNode[10]
-Rob Teixeira [MVP]
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:op**************@msnews.microsoft.com...
On Sun, 8 Feb 2004 00:58:21 +0100, cody <do*********************@gmx.de>
wrote:
The OP wanted to have functionality like this:
NodeChild nc = myNode.Child[10];
Without having to return an array. What he wanted, was a named indexer,
not
the anonymous one that C# provides.
I believe that is the Visual Basic way of doing it as myNode.Child(10)
(VB) would translate to myNode[10] (C#)
Same with things having a Thingy.Item(x) (VB) -> Thingy[10] (C#)
I could be very wrong.
--
The hotmail account will most likely not be read, so please respond only
to the news group.