Difference between CF and Full Framework ...

J

JustMe

Hello ...

I have a CF application that I'm trying to run on the full framework.
For the most part, everything works as expected. However there is one
piece of code that acts very much differently:

dim xstrng as string
xstrng = "12345678901"
messagebox.show(xstrng.Substring(11,1))

On the compact framework, the above code displays an empty string.

On the full framework, the above code errors out with:
Run-time exception thrown : System.ArgumentOutOfRangeException - Index
and length must refer to a location within the string.

Why is this? Is there some setting in the full framework that will
make the same code run as it does in the CF?

Your help is greatly appreciated,
--Terry
 
L

Lloyd Dupont

as your string as only 11 character I will say that the compact framework is
faulty in being too tolerant.
I will advice you to correct the bug by testing the length of the string
before accessing index 11 which is obviously out of range (string size being
11, index goes from 0 to 10)
 
J

Just Me

Thanks. I've already put in extra code to test for valid length. I
just wondered if it was actually a bug in CF or somethign else.

Thanks alot,
Terry
 
G

Guest

You are better off testing the string length anyway

Raising an exception takes time and memory, and will always take a lot longer than a simple .Length check

Regard

Liam Westley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top