473,770 Members | 5,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.Start sWith( "0x" )

the application throws and exception stating

error: 'sNormalPt.Star tsWith' 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.Lengt h
6
sNormalPt.Start sWith( "0x" )
error: 'sNormalPt.Star tsWith' does not exist
sNormalPt.EndsW ith( "D0" )
error: 'sNormalPt.Ends With' 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
Nov 17 '05 #1
6 6469
On Wed, 07 Sep 2005 00:40:30 -0700, LongBow <pi***@mud.pool > wrote:
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.Star tsWith( "0x" )

the application throws and exception stating

error: 'sNormalPt.Star tsWith' 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.Leng th
6
sNormalPt.Star tsWith( "0x" )
error: 'sNormalPt.Star tsWith' does not exist
sNormalPt.Ends With( "D0" )
error: 'sNormalPt.Ends With' 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" ?>
<configuratio n>
<startup>
<requiredRuntim e version="V1.1.4 322" />
</startup>
</configuration>

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

Mark
Nov 17 '05 #2
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.

Nov 17 '05 #3
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

Nov 17 '05 #4
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#.

Nov 17 '05 #5
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.

Nov 17 '05 #6
gmiley <gm****@gmail.c om> wrote:
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.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2216
by: Andy | last post by:
What do people think of this? 'prefixed string'.lchop('prefix') == 'ed string' 'string with suffix'.rchop('suffix') == 'string with ' 'prefix and suffix.chop('prefix', 'suffix') == ' and ' The names are analogous to strip, rstrip, and lstrip. But the functionality is basically this: def lchop(self, prefix):
1
149808
by: Robin Tucker | last post by:
Hi, I would like to select records from a table where the following criteria hold: SELECT * from Mytable where field x "contains" string @X or
3
3389
by: steve morin | last post by:
http://www.python.org/doc/2.4.1/lib/node110.html These methods are being deprecated. What are they being replaced with? Does anyone know? Steve
15
1478
by: Howard | last post by:
Hello, I'm new to c$ I need help writing a function that matches a word only if the word is at the end of a string example: string a = "I like google"; string b = "google I like"; string a would return true, b would return false secondly i need to write a function that checks if the length of my strings is less or equal to 20 characters. if more than 20 chars then
15
3666
by: manstey | last post by:
Hi, I have a text file called a.txt: # comments I read it using this:
21
25479
by: Michael | last post by:
Hi All, I've received (via UDP) a null terminated string and need to convert it into a Python string. Can anyone tell me how this is done? If it helps, I know the number of characters in the string. Thanks, M. McDonnell
25
12954
by: John Salerno | last post by:
Forgive my excitement, especially if you are already aware of this, but this seems like the kind of feature that is easily overlooked (yet could be very useful): Both 8-bit and Unicode strings have new partition(sep) and rpartition(sep) methods that simplify a common use case. The find(S) method is often used to get an index which is then used to slice the string and obtain the pieces that are before and after the separator....
4
3294
by: =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post by:
Hello, what is the use-case of parameter "start" in string's "endswith" method? Consider the following minimal example: a = "testing" suffix="ing" a.endswith(suffix, 2) Significance of "end" is obvious. But not so for "start".
4
18218
by: zacks | last post by:
I need to check the current value of a string value to see if it either starts with or ends with a double quote character, as in "123" (where the quotes are actual contens of the string). I thought a quotation character inside of a string is specified with two double quote characters. But when I code something like: string myString; if (myString.StartsWith("""")) {
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.