Using fuction in C#

  • Thread starter Thread starter Shahil Shah
  • Start date Start date
S

Shahil Shah

Hello

I would like to use the 'using' keyword (available in c#) in visual basic. I
have looked at the MSDN library but it does nat have this in vb. Does
anybody know of a similar keyword/function in vb?

Thanks

Shahil
 
Shahil Shah said:
I would like to use the 'using' keyword (available in c#) in visual basic.
I have looked at the MSDN library but it does nat have this in vb. Does
anybody know of a similar keyword/function in vb?

C# unfortunately overloads the 'using' keyword.

All versions of VB.NET contain an 'Imports' statement which is equivalent to
C#'s 'using <namespace>'.

VB 2005 has a 'Using' block which is basically the same as C#'s 'using'
block.

In previous versions of VB.NET the same behavior can be archieved like this:

\\\
Dim f As Foo = ... ' Implements 'IDisposable'.
Try
...
Catch
Finally
f.Dispose()
End Try
///
 
Thanks for that - I will give it a try

Herfried K. Wagner said:
C# unfortunately overloads the 'using' keyword.

All versions of VB.NET contain an 'Imports' statement which is equivalent
to C#'s 'using <namespace>'.

VB 2005 has a 'Using' block which is basically the same as C#'s 'using'
block.

In previous versions of VB.NET the same behavior can be archieved like
this:

\\\
Dim f As Foo = ... ' Implements 'IDisposable'.
Try
...
Catch
Finally
f.Dispose()
End Try
///
 
Back
Top