• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

try statement variables

 
Eric Giblock
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try
{
.....
int variable 1
int variable 2.
}
catch
{}




how can i access the values of the variables inside the try statement from outside the try statement??
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

You can't. You can move the declarations outside the try block:



Note that you may have to initialize the variables when they're declared, or the compiler may complain that the variables "may not have been initialized" when you access them in the catch block.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic