Tech Off Post

Single Post Permalink

View Thread: Ideas for C# 5.0
  • User profile image
    Evok

    Ion Todirel said:
    exoteric said:
    *snip*

    I'd really want grouped exceptions:

     

    try

    {

    }

    catch (SocketException)

    catch (WebException)

    {

        // some common handling here

    }

     

    vs.

     

    try

    {

    }

    catch (SocketException)

    {

        // some handling here

    }

    catch (WebException)

    {

        // same handling as above

    }

    or something like:

     

    try
    { 
        ... 
    }
    catch (System.IO.FileLoadException, System.IO.FileNotFoundException)
    {
        ...
    }
    

     

    This is something I've been wanting for a while.  I especially hate having one line of code catch blocks just because I needed to catch some random exception that I didn't want caught by System.Exception.  Something like this would make things look cleaner I think.