PC Review


Reply
Thread Tools Rate Thread

Alternative to IndexOutOfRangeException

 
 
Magnus.Moraberg@gmail.com
Guest
Posts: n/a
 
      25th Jun 2008
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.
 
Reply With Quote
 
 
 
 
Mick Wilson
Guest
Posts: n/a
 
      25th Jun 2008
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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Adsense Alternative - Commission Junction Alternative -ClickBank Alternative William9999 Windows XP Performance 0 2nd Nov 2010 09:02 AM
Google Adsense Alternative - Commission Junction Alternative -ClickBank Alternative William9999 Windows XP Performance 0 2nd Nov 2010 09:01 AM
IndexOutOfRangeException ... John Microsoft C# .NET 4 22nd Nov 2009 11:18 PM
IndexOutOfRangeException Peter Microsoft Dot NET Compact Framework 5 28th Jan 2005 08:26 PM
IndexOutOfRangeException =?Utf-8?B?QmlsbA==?= Microsoft Dot NET 0 24th Mar 2004 08:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:11 AM.