Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Implementing IDisposable in a class
Message
De
14/02/2014 10:12:39
 
 
À
14/02/2014 03:47:52
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01594093
Message ID:
01594303
Vues:
30
>Interesting. It does work in C# - I just ran my code thru a converter. TBH I don't think it should work in C# either - the docs for 'using' state:
>"Within the using block, the object is read-only and cannot be modified or reassigned." But this is allowed:
using (mySvc.Something = new OperationContext())
>                {
>                    mySvc.Something = new OperationContext();
>                };
>
whereas the following gives the expected error 'Readonly local variable cannot be used in any execution path':
using (var test = new OperationContext())
>                {
>                    test = new OperationContext();
>                };
Seems to me C# is letting an invalid construct slip past?

Probably, that would then explain the situation. Thanks for the additional input
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform