Beta2 C# breaks this code 
Author Message
 Beta2 C# breaks this code

This worked fine with Beta 1 but Beta 2 throws a
System.ArgumentOutOfRangeException.  Why??

string address;
int colonPos;
address = "N11:0";
colonPos = address.IndexOf(":", 1, address.Length);



Mon, 19 Jan 2004 05:54:36 GMT  
 Beta2 C# breaks this code
Nevermind, I found it.  Had to do address.Length - 1.


Quote:
> This worked fine with Beta 1 but Beta 2 throws a
> System.ArgumentOutOfRangeException.  Why??

> string address;
> int colonPos;
> address = "N11:0";
> colonPos = address.IndexOf(":", 1, address.Length);



Mon, 19 Jan 2004 06:00:53 GMT  
 Beta2 C# breaks this code
ArgumentOutOfRange exception is thrown in these cases:
"ArgumentOutOfRangeException count or startIndex is negative.
-or-
count plus startIndex specify a position not within this instance." (Source:
MS .NET SDK Documentation)

Since 1 + address.Lenth is more that the length of the string, exception is
rased. Use on of following syntaxes:
colonPos = address.IndexOf(":", 0, address.Length);
colonPos = address.IndexOf(":", 1, address.Length-1);

Todor Todorov
Developer


Quote:
> This worked fine with Beta 1 but Beta 2 throws a
> System.ArgumentOutOfRangeException.  Why??

> string address;
> int colonPos;
> address = "N11:0";
> colonPos = address.IndexOf(":", 1, address.Length);



Mon, 19 Jan 2004 06:06:08 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Back to VS.Net beta2, there was a code share plugin featured browsing code from Internet

2. Broken code or broken compiler?

3. Using RS232 with C# (.net beta2)

4. Where is the C# compiler in beta2?

5. PPT XP and C# Beta2

6. New C# Source Code Sample - Running JScript.NET Code from C# Apps

7. Moving code from Beta2 to RTM

8. Converting Beta1 code to Beta2 (forms)

9. lint on Altos 2000 is BROKE BROKE BROKE!

10. Simple Help: Line break formatting in C#

11. PRB: Building code tree from C# code using CodeDom

12. PRB: Building code tree from C# code using CodeDom

 

 
Powered by phpBB® Forum Software