Messy way to use a streamreader
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user