Click here to Skip to main content
16,014,591 members
Home / Discussions / C#
   

C#

 
AnswerRe: Array Management Pin
leppie5-Jun-08 0:20
leppie5-Jun-08 0:20 
GeneralRe: Array Management Pin
DwR5-Jun-08 0:26
DwR5-Jun-08 0:26 
GeneralRe: Array Management Pin
leppie5-Jun-08 1:16
leppie5-Jun-08 1:16 
AnswerRe: Array Management Pin
Ashfield5-Jun-08 0:29
Ashfield5-Jun-08 0:29 
AnswerRe: Array Management Pin
Sajjad Izadi5-Jun-08 0:57
Sajjad Izadi5-Jun-08 0:57 
GeneralRe: Array Management Pin
moon_stick5-Jun-08 1:39
moon_stick5-Jun-08 1:39 
GeneralRe: Array Management Pin
DaveyM695-Jun-08 12:01
professionalDaveyM695-Jun-08 12:01 
GeneralRe: Array Management Pin
Robert.C.Cartaino6-Jun-08 6:12
Robert.C.Cartaino6-Jun-08 6:12 
DaveyM69 wrote:
Is it just me or is this a REALLY bad idea - deliberatley causing an exception to be thrown?


No, It is not just you. I think it is bad design to use exceptions to handle the "normal and expected" flow of execution. When exceptions where first added to the C++, I started seeing code like:
open file;
try
{
    loop forever:
        read line from file;
}
catch
{
    // oops, we must have reached the end of the file
}

It not usually a good idea to use exceptions to manage the normal flow of execution for a couple of reasons. First, exceptions are expensive to handle so you will almost certainly degrade performance. Also, sprinkling try statements all over the place makes code difficult to read. Conceptually, the whole point of an "exception" is to indicate an exceptional condition (i.e. Out-of-memory) that cannot be easily handled at the time/place the error condition is reached. The whole idea of an exception should be to pass control of the program to a place that can handle the error condition.

If you are using exceptions in lieu proper bounds checking or verifying the return value of a method or API call, then, in reality, exceptions are just a high-tech way of implementing a GOTO which can leave your system in an undefined state. These are generalizations and "exception-neutral programming" outlines acceptable techniques for the best use of exceptions (See Exceptional C++, Herb Sutter).
GeneralRe: Array Management Pin
Sajjad Izadi13-Jun-08 21:09
Sajjad Izadi13-Jun-08 21:09 
AnswerRe: Array Management Pin
Guffa5-Jun-08 1:33
Guffa5-Jun-08 1:33 
AnswerRe: Array Management Pin
#realJSOP5-Jun-08 2:51
professional#realJSOP5-Jun-08 2:51 
GeneralRe: Array Management Pin
leppie5-Jun-08 3:08
leppie5-Jun-08 3:08 
GeneralRe: Array Management Pin
#realJSOP5-Jun-08 4:14
professional#realJSOP5-Jun-08 4:14 
GeneralRe: Array Management Pin
leppie5-Jun-08 4:46
leppie5-Jun-08 4:46 
AnswerRe: Array Management Pin
Bhumikabarot5-Jun-08 3:36
Bhumikabarot5-Jun-08 3:36 
GeneralRe: Array Management Pin
DwR5-Jun-08 5:07
DwR5-Jun-08 5:07 
QuestionHow i can add windows service using C# Code Pin
wasimsharp4-Jun-08 23:57
wasimsharp4-Jun-08 23:57 
AnswerRe: How i can add windows service using C# Code Pin
leppie5-Jun-08 0:21
leppie5-Jun-08 0:21 
GeneralRe: How i can add windows service using C# Code Pin
wasimsharp5-Jun-08 0:22
wasimsharp5-Jun-08 0:22 
QuestionHttpListener.BeginGetContext Pin
George_George4-Jun-08 23:55
George_George4-Jun-08 23:55 
AnswerRe: HttpListener.BeginGetContext Pin
Christian Flutcher5-Jun-08 1:17
Christian Flutcher5-Jun-08 1:17 
GeneralRe: HttpListener.BeginGetContext Pin
George_George5-Jun-08 1:31
George_George5-Jun-08 1:31 
GeneralRe: HttpListener.BeginGetContext Pin
N a v a n e e t h5-Jun-08 1:50
N a v a n e e t h5-Jun-08 1:50 
GeneralRe: HttpListener.BeginGetContext Pin
George_George5-Jun-08 2:02
George_George5-Jun-08 2:02 
GeneralRe: HttpListener.BeginGetContext Pin
N a v a n e e t h5-Jun-08 6:56
N a v a n e e t h5-Jun-08 6:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.