public void IndexOutOfRangeExceptionTask() { int n = 7; this.writer.Write("\n-----Task2-----IndexOutOfRangeException\n\n"); try { ExceptionSituations.InstantiateArray(n, 100); } catch (IndexOutOfRangeException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { MyLogger logger = new MyLogger(); logger.Info("\n-----Task2-----IndexOutOfRangeException\n\n", Operation.LoggingToConsole); int n = 7; try { ExceptionSituations.InstantiateArray(n, 100); } catch (System.IndexOutOfRangeException e) { logger.Error(e.Message, Operation.LoggingToConsole); } catch (System.Exception e) { logger.Error(e.Message, Operation.LoggingToFile); logger.ReadFromLogFile(); } }