using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication23 { class ExceptionNaN : Exception { public ExceptionNaN(string hlaska) : base( hlaska ) { } } class Program { static void Main(string[] args) { System.IO.StreamWriter sw = new System.IO.StreamWriter("soubor.txt"); int i=-1; while (true) { try { checked { double d = checked(Math.Sqrt(i)); if (double.IsNaN(d)) { throw new ExceptionNaN("Tohle prece neni cislo!"); } d = d / d; } i = 0; i = i / i; i = 57; break; } catch (ExceptionNaN e) { Console.WriteLine("Doslo k vyjimce:"); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); Console.WriteLine("...ale nebudu to nikde hlasit!"); i = 999; throw; } catch (DivideByZeroException) { i = 777; } finally { sw.Close(); Console.WriteLine("---finally--"); } } Console.WriteLine( i ); } } }