473,751 Members | 2,294 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 3034
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_avail able@wrote in message
news:9o******** *************** *********@4ax.c om...
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.nos pamwrote:
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
29679
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 says: "The 'visibility' property takes the value 'collapse' for row, row group, column, and column group elements. This value causes the entire row or column to be removed from the display, and the space normally taken up by the row or column to...
2
3486
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 repopulate the 2nd combo based upon the value of the selected item in the first, just like it does in IE.
9
6896
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
3226
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+2, the value 4 *is produced*. Nothing *happens*. Thus, 4 is the value of the expression, and it has no side effects. In the expression g=2.0, the value 2.0 is produced. What *happens* is that 2.0 is assigned to g. Thus, 2.0 is the value of the...
2
1562
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 = CType(sender, TextBox) txt.Text = txt.Text.ToUpper End Sub
48
3372
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 "toupper" function imposes a further constrait in that the value passed to it must be representable as a unsigned char. (If C does not require all character values to be positive, then again, this constrait too escapes me... ) Let's say we have the...
1
2187
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 copied and pasted most of this code from another form). Can anyone enlighten me please as to why this happens randomly and how to evercome it as It is driving me nuts. Thanks in advance for any assistance offered
55
6238
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 C# in some way? Or maybe no, because it is similar to a global variable (with its scope restricted) which C# is dead against? Zytan
2
6090
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 wrong? thanks, Joyce
0
9591
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...
1
9349
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
8269
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
6819
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
6090
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
4721
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
4899
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3330
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
3
2230
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.