By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

Alternative to IndexOutOfRangeException

P: n/a
Hi,

I have the following methods -

public MyClass this[int index]
public MyClass this[string myClassName]

if this[int index] recieves an index which is outside the bounds of
the concerned array, I throw - IndexOutOfRangeException

What exception should I throw if no object in the concerned array has
the name myClassName, for this[string myClassName]?

Thanks,

Barry.
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jun 25, 9:16*am, Magnus.Morab...@gmail.com wrote:
What exception should I throw if no object in the concerned array has
the name myClassName, for this[string myClassName]?
If you're using the string myClassName as a key to your collection,
you can use the KeyNotFoundException.

http://msdn.microsoft.com/en-us/libr...exception.aspx
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.