R
Robert Jacobson
Hi,
I'm trying to get a reference to an object in a collection. If the indexer
is outside of the range, it should return null, without raising an
IndexOutOfRange exception.
I'm currently using the conditional operator to do this, which is rather
kludgy:
TreeNode currentNode = i < nodes.Count ? nodes : null;
I vaguely recall another C# language construct that did the same thing
(return the object or null), but a bit more elegantly. Assuming I'm not
totally off-base, could anyone point me in the right direction?
Thanks,
Robert Jacobson
I'm trying to get a reference to an object in a collection. If the indexer
is outside of the range, it should return null, without raising an
IndexOutOfRange exception.
I'm currently using the conditional operator to do this, which is rather
kludgy:
TreeNode currentNode = i < nodes.Count ? nodes : null;
I vaguely recall another C# language construct that did the same thing
(return the object or null), but a bit more elegantly. Assuming I'm not
totally off-base, could anyone point me in the right direction?
Thanks,
Robert Jacobson