Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Implementing IDisposable in a class
Message
From
14/02/2014 10:12:39
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01594093
Message ID:
01594303
Views:
31
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform