473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1119

"AliRezaGoogle" <as*******@yahoo.comwrote in message
news:0f**********************************@x35g2000 hsb.googlegroups.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
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...
5
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...
22
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...
7
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...
5
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...
2
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...
5
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...
3
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 ...
2
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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,...
0
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...

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.