Problems with String's StartsWith and EndsWith in VS.NET 2003

  • Thread starter Thread starter LongBow
  • Start date Start date
L

LongBow

Hello all,

I am having a little problems getting String's StartsWith and
EndsWith methods. If I have a string defined as

sNormalPt which equals "0x11D0" then use the following command

sNormalPt.StartsWith( "0x" )

the application throws and exception stating

error: 'sNormalPt.StartsWith' does not exist

I get the same behavior using the EndsWith method also. The following
is the output from the command window as I typed commands

sNormalPt
"0x11D0"
sNormalPt.Length
6
sNormalPt.StartsWith( "0x" )
error: 'sNormalPt.StartsWith' does not exist
sNormalPt.EndsWith( "D0" )
error: 'sNormalPt.EndsWith' does not exist

I don't understand why this is failing, does any one have some clues?
I do have Visual C# Express Beta 2 installed, so perhaps that has
something to do with it????

Mark
 
Hello all,

I am having a little problems getting String's StartsWith and
EndsWith methods. If I have a string defined as

sNormalPt which equals "0x11D0" then use the following command

sNormalPt.StartsWith( "0x" )

the application throws and exception stating

error: 'sNormalPt.StartsWith' does not exist

I get the same behavior using the EndsWith method also. The following
is the output from the command window as I typed commands

sNormalPt
"0x11D0"
sNormalPt.Length
6
sNormalPt.StartsWith( "0x" )
error: 'sNormalPt.StartsWith' does not exist
sNormalPt.EndsWith( "D0" )
error: 'sNormalPt.EndsWith' does not exist

I don't understand why this is failing, does any one have some clues?
I do have Visual C# Express Beta 2 installed, so perhaps that has
something to do with it????

Mark



Hello again,

I found out that that most of the string methods are not working.
Here are a few that I tried and they failed providing me with the same
error message.

ToUpper()
ToLower()
SubString()

I also added a config file in case the .NET 2.0 was causing problems
which looks like

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<requiredRuntime version="V1.1.4322" />
</startup>
</configuration>

With this even in the debug folder it doesn't help....

Mark
 
I duplicated your problem using VS2003 and I do not have .Net 2.0
installed on this machine, so I don't think that has anything to do
with it.

The methods (EndsWith, StartsWith) all work correctly in code, just not
in the command window when using C#. It also does *not* work for me in
the watch windows

It *does* work correctly when using VB.Net in both cases. I'm not sure
why C# doesn't allow that type of evaluation in the command window or
watch windows. That would seem to be a severe limitation to debugging.
 
Chris,

Since I debugging the application I hadn't tried running the
application normally, but after reading your post I let it run normally
and the string methods do function correctly. As you already stated
this does limit debugging fairly severely. Was this topic talked about
before? I didn't see anything and should this item be submitted to
Microsoft? If so, how would one submit this?

Mark
 
I have not seen it before. I work primarily with VB.Net and it works
correctly in the IDE for VB. I find it strange that it doesn't for C#.
 
I can only assume that it has to do with string actually being char[].
It may be possible that in C# debug mode it makes that distinction,
while in VB debug mode, it does not. So while intellisense shows the
methods as being available, they actually are not.

In the test code I wrote:

string testString = "blah blah blah blah";

using the command window after hitting the break:

(testString[0] == 'b')
true

A lot of the functions that retrieve data or operate based on a strings
underlying char[] type do not operate propperly in the debug mode
command window.
 
gmiley said:
I can only assume that it has to do with string actually being char[].

No, string and char[] are fairly different. While string does contain a
sequence of chars, it isn't really an array.
It may be possible that in C# debug mode it makes that distinction,
while in VB debug mode, it does not. So while intellisense shows the
methods as being available, they actually are not.

In the test code I wrote:

string testString = "blah blah blah blah";

using the command window after hitting the break:

(testString[0] == 'b')
true

A lot of the functions that retrieve data or operate based on a strings
underlying char[] type do not operate propperly in the debug mode
command window.

There *is* no underlying char[] type. The above uses the *indexer* of a
string, which doesn't mean it's actually an array.
 

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

Back
Top