Re: try catch question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I know this will sound like a really stupid question, but here goes. I
am in the middle of debugging someone else's code and am getting more
confused by the second. Does the try catch require an "end Try"?
There are try's and catches everywhere, but no end trys.

If when you get finished having a good laugh and feel up to posting a
reply, I would be most grateful for any advice.

Oh and if anyone knows of a quick way to check that braces match up -
I think the squiggly braces aren't always paired as they should be.

Hey Dawn I think you're reading c# code not vb.net

So your code might look like

-------------------------------------------------------------
try
{
// try something
}
catch exception ex
{
// do some catch stuff
}
-------------------------------------------------------------

However the nature of c# allows for the braces to be placed on other lines thus...
-------------------------------------------------------------
try { // try something
}
catch exception ex {
// do some catch stuff
}
-------------------------------------------------------------

Note that the opening braces are not parrallel with the closing ones.

In this case (c#), the end brace '}' is equivilent to 'End Try'

I hope this helps

--
Rory


.



Relevant Pages

  • [PATCH 04/13] checkpatch: allow parentheses on return for comparisons
    ... It seems to be a common idiom to include braces on conditionals in all ... contexts including return. ... Allow this exception to the return is not ...
    (Linux-Kernel)
  • Re: try catch question
    ... I think the squiggly braces aren't always paired as they should be. ... catch exception ex { ... Is it possible to use C# conventions in a vb.net program? ... If I am understanding the answers posted here, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Why does the try statement (and catch clause) require a block?
    ... Jon Shemitz wrote: ... catch (Exception e) ... For that reason, it makes ... sense to require the braces to make it a formal block. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Coding Conventions?
    ... Brace on the sig line? ... Braces on seperate ... class and method definitions on one line(with the exception of the ... where operator or inheritets\implements lists of more than about 3 items,) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need help with loop
    ... The for loop has only one line, ... Note that in the original post there were three opening braces and three closing braces. ...
    (comp.lang.java.help)