what is Using keyword in VB.net ?
-
hello ! can u tell me what is Using keyword in VB.net ? what it do ? and if i want to write a keyword like this in C#, which keyword should i use ?
The Using keyword simply sticks a Dispose call at the end of the code. For example:
Using(sw As New StreamWriter("C:/TestFile.txt"))
sw.WriteLine("Aloha!")
End Usingbecomes
Try
Dim sw As New StreamWriter("C:/TestFile.txt")sw.WriteLine("Aloha!")
Finally
sw.Dispose()
End TryThe keyword in C# is
using
; it's case sensitive, unlike VB.NetBetween the idea And the reality Between the motion And the act Falls the Shadow
-
hello ! can u tell me what is Using keyword in VB.net ? what it do ? and if i want to write a keyword like this in C#, which keyword should i use ?
-
The Using keyword simply sticks a Dispose call at the end of the code. For example:
Using(sw As New StreamWriter("C:/TestFile.txt"))
sw.WriteLine("Aloha!")
End Usingbecomes
Try
Dim sw As New StreamWriter("C:/TestFile.txt")sw.WriteLine("Aloha!")
Finally
sw.Dispose()
End TryThe keyword in C# is
using
; it's case sensitive, unlike VB.NetBetween the idea And the reality Between the motion And the act Falls the Shadow
It does more for you than just call
Dispose
in the manner in which you describe. It also wraps it in aTry
/Finally
block too so thatDispose
is always called even in the event that an exception is raised. This is where its real usefulness lies. It is much easier to write theUsing
block that it would two write all the corresponsingTry
/Finally
stuff to do the same thing.User group: Scottish Developers Blog: Can Open... Worms? Everywhere! Quote: Man who stand on hill with mouth open wait long time for roast duck to drop in.
-
The "using" Keyword in C#[^] I THINK IT'S HALPFUL FOR U. BEST REGARD
If you can think then I Can.
eg_Anubhava wrote:
I THINK IT'S HALPFUL FOR U.
I NOT DEAF! PLEASE STOP SHOUTING! It is very rude to use all caps.
User group: Scottish Developers Blog: Can Open... Worms? Everywhere! Quote: Man who stand on hill with mouth open wait long time for roast duck to drop in.
-
It does more for you than just call
Dispose
in the manner in which you describe. It also wraps it in aTry
/Finally
block too so thatDispose
is always called even in the event that an exception is raised. This is where its real usefulness lies. It is much easier to write theUsing
block that it would two write all the corresponsingTry
/Finally
stuff to do the same thing.User group: Scottish Developers Blog: Can Open... Worms? Everywhere! Quote: Man who stand on hill with mouth open wait long time for roast duck to drop in.