Messy way to use a streamreader

This commit is contained in:
2019-01-09 23:03:13 +01:00
parent 7b3e8c17c2
commit f455ac39ff

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -10,19 +11,12 @@ namespace Exceptionhandling
{
static void Main(string[] args)
{
StreamReader streamreader = null;
try
{
var calculator = new Calculator();
var result = calculator.Divide(5, 0);
}
catch (DivideByZeroException dx)
{
Console.WriteLine("You cannot divide by 0.");
}
catch (ArithmeticException ax)
{
Console.WriteLine("");
streamreader = new StreamReader(@"c:\file.zip");
var content = streamreader.ReadToEnd();
}
catch (Exception ex)
{
@ -30,6 +24,8 @@ namespace Exceptionhandling
}
finally
{
if (streamreader != null)
streamreader.Dispose();
}
}
}