Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variable scope and try and catch
Message
De
17/09/2003 17:02:29
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00829818
Message ID:
00830111
Vues:
26
This message has been marked as a message which has helped to the initial question of the thread.
Dmitry,

Plamen already got it, but you may have missed it. If you intialize your variables with null prior to the try/catch, it should still work.
SqlCommand sc = null;
DataReader dr = null;
// etc.
try
{
    sc = new SqlCommand();
    // and all the rest of the stuff
}
catch (SqlException ex)
{
}
~~Bonnie

>>>>
>>Don't want to answer for Plamen, but you didn't get it right. You have to initialize all variables prior to try/finally block.
>
>That's not my understanding. The idea of TRY is to try to initialize things to see if they work and if they don't catch them. I know I have to declare them prior to TRY but it is different from initializing. Perhaps Plamen or Bonnie will correct me or you :-)
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform