473,662 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String function not working while debugging.

Hi all,

I am facing some wierd problem in quick watch at a time of debugging
my application.

I have one variable of type string, say suppose i have code as below:

string FileName;
FileName = FileName.Substr ing(0,FileName. LastIndexOf("." ));

At a time of debugging if i check value of filename it is displaying
value properly,

But when i try to add quick watch for expression
FileName.Substr ing(0,FileName. LastIndexOf("." )), it is giving me error
message that 'error: 'FileName.Subst ring' does not exist '

I don't know why this happening.

Or is it like that, i can't apply quick watch on string function while
debugging.

any help will be truely appreciated.

Thanks in advance.
Archana.

Feb 3 '06 #1
6 1805
I think it is like that only. Even you can't evaluate the functions of
int datatype.

Feb 3 '06 #2
Hi,
thanks for ur reply.

So means there is no other alternative to exeute function at runtime
other that storing value of those variables into variable and checking
value of that variable.

If u know any other alternative please tell me.

Thanks.

Feb 3 '06 #3
I could not figureout the exact way but, I created a simple class as
following

public class Test
{
public int i=10;

public int GetI()
{
return i;
}
}

I could execute GetI() function in debug mode. I think what we can
conclude from it is, the functions on the valuetypes can't be executed
in debug mode. I also tried to execute functions of hashtable in debug
mode and I got success.

Feb 3 '06 #4
Biren Prajapati <se*********@gm ail.com> wrote:
I could not figureout the exact way but, I created a simple class as
following

public class Test
{
public int i=10;

public int GetI()
{
return i;
}
}

I could execute GetI() function in debug mode. I think what we can
conclude from it is, the functions on the valuetypes can't be executed
in debug mode. I also tried to execute functions of hashtable in debug
mode and I got success.


That wouldn't explain string not working for you, as string is a
reference type.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 3 '06 #5
I know string is a reference type but you would be knowing that string
is a special type which whenever assigned to another type of string
variable, the reference is not copied but another instance of that
string is created and copied into that string. Which is not the same in
other reference types.

Feb 7 '06 #6
Biren Prajapati wrote:
I know string is a reference type but you would be knowing that string
is a special type which whenever assigned to another type of string
variable, the reference is not copied but another instance of that
string is created and copied into that string. Which is not the same in
other reference types.


You're mistaken. No copy is made, and string acts like any other
reference type. It happens to be immutable, that's all. There are a few
ways in which String is special:

1) The CLR knows about it (for literals etc)
2) Literals are interned
3) The C# compiler handles concatenation using String.Concat
automatically.
4) There's a corner-case where calling the string constructor doesn't
actually create a new string (but only in a specific situation).

Other than that, it acts as any other reference type.

As String is immutable, it would be utter folly for a new instance to
be created every time the reference were assigned to another variable.
Here's a short but complete program which demonstrates that your claim
is incorrect:

using System;

class Test
{
static void Main()
{
// Avoiding using literal strings here just in
// case people think that's what's making it work...
string x = DateTime.Now.To String();
string y = x;
Console.WriteLi ne (object.Referen ceEquals(x, y));
}
}

Jon

Feb 7 '06 #7

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

Similar topics

4
1535
by: jdn | last post by:
Driving me nuts. Web page calls a function in a different class library that is to return a string. Inside this function, I create a string, give it a value, then try to do a string.replace. Fails. Though I can do stringname.length and get the property, if I try any of the methods (Replace, Remove, ToUpper, ToLower, etc.), it tells me:
2
4773
by: Andrew | last post by:
I have written two classes : a String Class based on the book " C++ in 21 days " and a GenericIpClass listed below : file GenericStringClass.h // Generic String class
9
7125
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but when I tried the program on the Win98 system it will be running on, I get the following error: Cast from string "2076719" to type 'Long' is not valid I am not sure why I only get this error on the Win98 system or how to go about correcting...
11
5339
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not (strIn.Substring(410, 10).Trim = "") Then 'Something processed Else 'Something processed
16
6157
by: BBM | last post by:
This is so bizarre I hesitate to post it, but I need to get this working. My code looks like this... Private Const cmdTestResourcesSel = "SELECT * FROM TResources" & _ " WHERE Scenario = @Scenario" Dim cmdstr as String cmdstr = cmdTestResourcesSel
8
1344
by: bob | last post by:
Hi, I'm working on fixing issues/bugs in a legacy codebase. I'd like to ask experts opinion on a decision I've made regarding a function. I don't have my Scott Meyers at hand but I'm fairly sure he mentions this issue. consider virtual function;
14
2508
by: deko | last post by:
geturl.php Too much code to paste here, but have a look at http://www.liarsscourge.com/ So far, I have not found a string that can break this... Any built-in functions or suggestions for improvement? Thanks in advance.
2
3613
by: HerbD | last post by:
I have a loooong debugging session behind me! I finally found the reason for the problem and now would like to know, if it is a bug in my code or not standardconformant behavour of the compiler(s) or not a bug at all and just normal behavior: This simple sample program illustrates the problem. Please use separate header (.h) and code (.cpp) files, because it plays a role in the problem... /************************************** * Module: ...
13
2837
by: Jennifer.Berube | last post by:
well I'm not sure how to go about making my SQL connection string... The code below is what I need to replace with my SQL connection...I just don't know if that code is for DSN or access... I don't want to use DSN just a connection string...help? function GetConnection() const DSN = "membershipdb" const UID = "webuser"
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8856
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
8633
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
7365
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...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
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...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.