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