473,513 Members | 11,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does tsSource[j].Text.ToUpper() causes side effects

I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and will
not be evaluated string
The Text is &Edit

Do you know what are the side effects?

Thanks
Mar 16 '08 #1
4 3017
On Sun, 16 Mar 2008 02:45:41 -0400, "Academia" <ac************@a-znet.com>
wrote:
>I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and will
not be evaluated string
The Text is &Edit

Do you know what are the side effects?
There probably aren't any in this case, but the debugger is not smart enough
to be able to tell - so it prefers to err on the safe side.

Quoting from http://msdn2.microsoft.com/en-us/library/a7a250bs.aspx :

"A side effect occurs when evaluating an expression changes the value of data
in your application.

Side effects are something to watch for if you are evaluating expressions in
the debugger. If you evaluate an expression in the Watch window or the
QuickWatch dialog box and the expression has side effects, you might change
the value of variables in another part of your program without realizing it.
Side effects can make debugging more difficult by creating the appearance of
bugs where none exist or masking the appearance of real bugs.

One common cause of side effects is evaluating a function call in a debugger
window. Such evaluations are usually noticeable. A more subtle cause of side
effects is the evaluation of properties and other implicit function calls in
managed code.

The debugger cannot tell whether a property evaluation or implicit function
call has side effects. Therefore, by default, the debugger does not evaluate
implicit function calls automatically. Property evaluation is allowed by
default, but can be turned off in the Options dialog box. When a function call
or property has not been evaluated, a refresh icon appears. You can manually
evaluate the expression by clicking the refresh icon. For details, see How to:
Refresh Watch Values."

Regards,
Gilles.

Mar 16 '08 #2
Thanks for the help

"Gilles Kohl [MVP]" <no_email_available@wrote in message
news:9o********************************@4ax.com...
On Sun, 16 Mar 2008 02:45:41 -0400, "Academia" <ac************@a-znet.com>
wrote:
>>I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and will
not be evaluated string
The Text is &Edit

Do you know what are the side effects?

There probably aren't any in this case, but the debugger is not smart
enough
to be able to tell - so it prefers to err on the safe side.

Quoting from http://msdn2.microsoft.com/en-us/library/a7a250bs.aspx :

"A side effect occurs when evaluating an expression changes the value of
data
in your application.

Side effects are something to watch for if you are evaluating expressions
in
the debugger. If you evaluate an expression in the Watch window or the
QuickWatch dialog box and the expression has side effects, you might
change
the value of variables in another part of your program without realizing
it.
Side effects can make debugging more difficult by creating the appearance
of
bugs where none exist or masking the appearance of real bugs.

One common cause of side effects is evaluating a function call in a
debugger
window. Such evaluations are usually noticeable. A more subtle cause of
side
effects is the evaluation of properties and other implicit function calls
in
managed code.

The debugger cannot tell whether a property evaluation or implicit
function
call has side effects. Therefore, by default, the debugger does not
evaluate
implicit function calls automatically. Property evaluation is allowed by
default, but can be turned off in the Options dialog box. When a function
call
or property has not been evaluated, a refresh icon appears. You can
manually
evaluate the expression by clicking the refresh icon. For details, see How
to:
Refresh Watch Values."

Regards,
Gilles.

Mar 17 '08 #3
Academia wrote:
I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and
will not be evaluated string
I rather suspect the message is "This expression causes no side effects".

What you've asked for is:
Find the jth item.
Read it's Text property.
Make an uppercase copy.
Throw away the result.
Mar 18 '08 #4
On Tue, 18 Mar 2008 09:02:26 -0700, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:
Academia wrote:
>I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and
will not be evaluated string

I rather suspect the message is "This expression causes no side effects".

What you've asked for is:
Find the jth item.
Read it's Text property.
Make an uppercase copy.
Throw away the result.
"Watch message" implies debugger. What you're describing would be a
problem if the compiler were looking at the expression, but here the
result of the expression isn't thrown away, it's (in theory) displayed to
the user.

In practice, it seems that it's not being displayed, because the debugger
believes it causes side-effects and thus won't evaluate it. Why that
should be, I don't know...I can't reproduce the same problem (my debugger
seems perfectly happy to put a call to ToUpper() in the watch window, even
when the source is some variable or property). But it's not hard to
believe that the debugger is hesitate to call a method in the watch window
because of the possibility of a side-effect.

Pete
Mar 18 '08 #5

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

Similar topics

3
29661
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification...
2
3477
by: mark4asp | last post by:
Why does this not work in Mozilla ? <http://homepage.ntlworld.com/mark.pawelek/code/animals.html> The optHabitat_change() event does not fire. What am I doing wrong here? PS: It should...
9
6880
by: Rouben Rostamian | last post by:
Consider the following illustrative program: #include <stdio.h> double f(double x) { return x*x; } double g(double x)
5
3205
by: Niklaus | last post by:
This is one of the posts that i got. ------------------------------ A "side effect" of an operation is something that *happens*, not something that *is produced*. Examples: In the expression...
2
1544
by: barry | last post by:
I am using the following code in a textbox: Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim txt As TextBox =...
48
3312
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The...
1
2167
by: Iain | last post by:
I have the following .net page with a pushbutton in a datagrid. This pushbutton should delete the selected record. It works in the same manner in many other pages of the same format (I actually...
55
6151
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
2
6075
by: joyce | last post by:
hi group, When I was trying to do a match on Regex.isMatch("$test",@"^\$") this seems to return "this expression causes side effects and will not be be evaluated", any ideas what I'm doing...
0
7254
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,...
0
7153
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
7373
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
7432
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
7519
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...
1
5079
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
3230
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...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
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.