473,597 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doesn't "checked" work for sub calls?

Dear Members
Hi,
I have a question:
Why doesn't "checked" work for sub calls? For example consider the
following snippet of code:

checked
{
Overflower();
}

void Overflower()
{
int t=int.MaxValue;
t++;
}

Why Overflower doesn't throw overflow exception?
Sep 17 '08 #1
1 1127

"AliRezaGoo gle" <as*******@yaho o.comwrote in message
news:0f******** *************** ***********@x35 g2000hsb.google groups.com...
Dear Members
Hi,
I have a question:
Why doesn't "checked" work for sub calls?
A fairly complex path could be created if allowed.

Imagine something like this:

public static void Main()
{
checked
{
RunProgram();
}
}

Can you imagine the overhead with this? Ouch!
For example consider the
following snippet of code:

checked
{
Overflower();
}

void Overflower()
{
int t=int.MaxValue;
t++;
}

Why Overflower doesn't throw overflow exception?
Because it is not checked.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think outside the box! |
*************** *************** **************

Sep 17 '08 #2

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

Similar topics

40
3014
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the goodness of Python whenever I talk with fellow developers, but I always hit a snag when it comes to discussing the finer points of the execution model (specifically, exceptions). Without fail, when I start talking with some of the "old-timers"...
5
1195
by: VB Programmer | last post by:
I want to set the enabled property of a text box based on if a checkbox is checked or not. This works.... txtPort.Enabled = ckDefaultPort.Checked; But, I want the enabled property to be the opposite of the checked value. Why doesn't this work? txtPort.Enabled = Not ckDefaultPort.Checked;
22
22283
by: campbellbrian2001 | last post by:
Thanks in Advance! ... I have two textboxes: 1 is visible (and gets its value based on the invisible textbox and displays either "Male" or "Female", and needs to display either male of female based on the value that comes up in the tables record as "M" or "F". I tried: =Iff((!)="M","Male","Female") 'the is form, is the textbox name
7
2223
by: relient | last post by:
Question: Why can't you access a private inherited field from a base class in a derived class? I have a *theory* of how this works, of which, I'm not completely sure of but makes logical sense to me. So, I'm here for an answer (more of a confirmation), hopefully. First let me say that I know people keep saying; it doesn't work because the member "is a private". I believe there's more to it than just simply that... Theory: You inherit,...
5
2442
by: Notgiven | last post by:
I have tried for several days to install and use aspell. I easily installed on my development computer which is Windows XP. I am trying to get it to run on a linux box now and am getting to the point to tell the client, it just can't be done. It seems I am almost there but can't get it all the way. For my latest test of the pre-compiled version I found contains three cirectories:
2
3910
by: keithtracypierce | last post by:
1)Access2003, beating my head against the wall, every other iteration is "can't find macro Upshift" followed by carefully verifying that no blank properties have been entered. Making NO changes at all, sometimes the message goes away, sometimes not. Any clues? 2)The other headbeating iterations are due to no joy when trying to allow T,F,Blank in a 1-character field, with AutoTab enabled. InputMask:>C;; DefaultValue:
5
9419
by: Barry | last post by:
I've wasted the whole day trying things and researching, but nothing is working. I would *greatly* appreciate if someone can give me the solution to this problem. I'm using the .NET Framework 2.0 in C# with a Master page and additional .aspx pages with .cs code-behind pages in Windows XP. In an .aspx page I have declared a control as follows: <asp:RadioButton runat="server" GroupName="rbtnS0" ID="rbtnS0start" />
3
4184
simpleton
by: simpleton | last post by:
Hey all, I'm new to this board. I'm trying to send email via a "contact us" form .asp page. I've setup SMTP Virtual Server on my local XP IIS 5.1 machine. I told it to relay with 127.0.0.1 The asp page acts like it works, but no email comes through. I initially set the page up with CDONTS (as the tutorial explained): http://www.webthang.co.uk/Tuts/tuts_dmx/dmxf_5/dmx5_3.asp
2
2813
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files comprising each report. I want the user to be able to select an arbitrary collection of report files and have them emailed by clicking an "Email selected files" button. Everything displays properly, including the checkboxes for each child row (each...
0
7977
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
8381
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
8044
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
8261
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...
1
5847
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
5437
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
3936
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2409
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
1
1496
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.