473,508 Members | 2,159 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.Substring(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.Substring(0,FileName.LastIndexOf(".")), it is giving me error
message that 'error: 'FileName.Substring' 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 1791
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*********@gmail.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.com>
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.ToString();
string y = x;
Console.WriteLine (object.ReferenceEquals(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
1529
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....
2
4760
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
7110
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...
11
5325
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...
16
6137
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 =...
8
1339
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...
14
2472
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...
2
3603
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...
13
2829
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...
0
7124
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...
0
7326
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,...
0
7385
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...
0
7498
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...
0
5629
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,...
1
5053
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...
0
4707
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
418
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...

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.