Click here to Skip to main content
15,910,981 members
Home / Discussions / C#
   

C#

 
AnswerRe: ptz camera control Pin
CDP180210-Mar-10 1:00
CDP180210-Mar-10 1:00 
Question[SOLVED] Catching several (hierarchically unrelated) exceptions in the same catch block Pin
blackblizzard9-Mar-10 23:49
blackblizzard9-Mar-10 23:49 
AnswerRe: Catching several (hierarchically unrelated) exceptions in the same catch block Pin
#realJSOP10-Mar-10 0:07
professional#realJSOP10-Mar-10 0:07 
GeneralRe: Catching several (hierarchically unrelated) exceptions in the same catch block Pin
blackblizzard10-Mar-10 0:10
blackblizzard10-Mar-10 0:10 
AnswerRe: Catching several (hierarchically unrelated) exceptions in the same catch block Pin
Keith Barrow10-Mar-10 0:09
professionalKeith Barrow10-Mar-10 0:09 
GeneralRe: Catching several (hierarchically unrelated) exceptions in the same catch block Pin
blackblizzard10-Mar-10 0:12
blackblizzard10-Mar-10 0:12 
AnswerRe: [SOLVED] Catching several (hierarchically unrelated) exceptions in the same catch block Pin
AspDotNetDev10-Mar-10 12:47
protectorAspDotNetDev10-Mar-10 12:47 
GeneralRe: [SOLVED] Catching several (hierarchically unrelated) exceptions in the same catch block Pin
blackblizzard10-Mar-10 20:31
blackblizzard10-Mar-10 20:31 
Thanks for your answers.
As you say, they're not pretty (but I appreciate them! Smile | :) ), so I'll stick with the method.

In particular:
1) Like many other people, I don't really like using labels and gotos in a high-level language.
2) GetType() is computationally expensive (not extremely so, but you know, reflection). Plus, I don't think you need a goto in this case. Couldn't you just do this?

private static void Main(string[] args)
{
    try
    {
        throw new InvalidOperationException("oops");
    }
    catch (Exception ex)
    {
        switch (ex.GetType().ToString())
        {
            case "System.InvalidOperationException":
            case "System.InvalidTimeZoneException":
                Console.WriteLine(ex.ToString());
                return;
            case "System.Exception":
                Console.WriteLine("Exception: " + ex.ToString());
                break;
            default:
                Console.WriteLine("Hmmm.");
                break;
        }
    }
}


Anyway, as suggested, I'll just use a method.
Thanks!
GeneralRe: [SOLVED] Catching several (hierarchically unrelated) exceptions in the same catch block Pin
AspDotNetDev10-Mar-10 20:50
protectorAspDotNetDev10-Mar-10 20:50 
GeneralRe: [SOLVED] Catching several (hierarchically unrelated) exceptions in the same catch block Pin
blackblizzard10-Mar-10 21:10
blackblizzard10-Mar-10 21:10 
GeneralRe: [SOLVED] Catching several (hierarchically unrelated) exceptions in the same catch block Pin
AspDotNetDev10-Mar-10 21:55
protectorAspDotNetDev10-Mar-10 21:55 
GeneralRe: [SOLVED] Catching several (hierarchically unrelated) exceptions in the same catch block Pin
blackblizzard10-Mar-10 22:00
blackblizzard10-Mar-10 22:00 
QuestionSending email and keeping a copy on the server Pin
eyalbi0079-Mar-10 22:53
eyalbi0079-Mar-10 22:53 
AnswerRe: Sending email and keeping a copy on the server Pin
Gerrit44410-Mar-10 0:07
Gerrit44410-Mar-10 0:07 
AnswerRe: Sending email and keeping a copy on the server Pin
DX Roster10-Mar-10 0:24
DX Roster10-Mar-10 0:24 
GeneralRe: Sending email and keeping a copy on the server Pin
Saksida Bojan10-Mar-10 5:42
Saksida Bojan10-Mar-10 5:42 
GeneralRe: Sending email and keeping a copy on the server Pin
eyalbi00714-Mar-10 0:18
eyalbi00714-Mar-10 0:18 
GeneralRe: Sending email and keeping a copy on the server Pin
Saksida Bojan14-Mar-10 2:04
Saksida Bojan14-Mar-10 2:04 
Questionaudio sound suite for .net crack Pin
Fatemi9-Mar-10 22:43
Fatemi9-Mar-10 22:43 
GeneralRe: audio sound suite for .net crack Pin
harold aptroot9-Mar-10 23:14
harold aptroot9-Mar-10 23:14 
GeneralRe: audio sound suite for .net crack Pin
Fatemi9-Mar-10 23:33
Fatemi9-Mar-10 23:33 
GeneralRe: audio sound suite for .net crack Pin
harold aptroot9-Mar-10 23:43
harold aptroot9-Mar-10 23:43 
GeneralRe: audio sound suite for .net crack Pin
The Man from U.N.C.L.E.9-Mar-10 23:47
The Man from U.N.C.L.E.9-Mar-10 23:47 
GeneralRe: audio sound suite for .net crack Pin
harold aptroot10-Mar-10 0:06
harold aptroot10-Mar-10 0:06 
GeneralRe: audio sound suite for .net crack Pin
#realJSOP10-Mar-10 1:44
professional#realJSOP10-Mar-10 1:44 

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.