C# C# Streams and Data Processing Streaming Data on the Net Searching for News Headlines

Why does she not Wrap the "var webClient = new WebClient();" in a using statement?

According to the code challenges the WebClient() method inherits form IDisposable, and it requires us to use a using statement.

2 Answers

Steven Parker
Steven Parker
177,931 Points

Calling Dispose() on a WebClient doesn't actually do anything useful. It implements IDisposable only because it inherits that interface from the base class (Component).

This probably should have been mentioned in the previous video about WebClient (but I don't think it was).

            using (var webClient = new WebClient())