When you use the
using statement, you ensure that your variable will be properly disposed at the end of the procedure.
So the class of the variable you are using must implement the
IDisposable interface.
Thus :
using (WebClient client = new WebClient())
{
}
is strictly equivalent to :
WebClient client = new WebClient();
client.Dispose();
Hope this helps.
[EDIT]
Actually, the above is not quite correct:
It is strictly equivalent to:
{
WebClient client;
try
{
client = new WebClient();
}
finally
{
if (client != null)
client.Dispose();
}
}
[/EDIT]