Tsallaka zuwa abun ciki
Justice Tech School

using and IDisposable

using disposes a resource when the block ends, even after an error.

Example
using var w = new StringWriter();
w.Write("hello");
Console.WriteLine(w.ToString());
using (var r = new StringReader("a\nb"))
{
    Console.WriteLine(r.ReadLine());
}

Exercise

Auto dispose.

 var r = new R();

Quiz Test

What does using call at the end?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.