Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exceptionExample
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine(FuncaDoodleDoo());
  10.         }
  11.         static int FuncaDoodleDoo()
  12.         {
  13.             int num = 0;
  14.             for (int i = 0; i < 10; i++)
  15.             {
  16.                 try
  17.                 {
  18.                     if (i == 1)
  19.                     {
  20.                         continue;
  21.                     }
  22.                     if (i == 2)
  23.                     {
  24.                         throw new Exception();
  25.                     }
  26.                     if (i == 3)
  27.                     {
  28.                         break;
  29.                     }
  30.                 }
  31.                 catch
  32.                 {
  33.                     num--;
  34.                 }
  35.                 finally
  36.                 {
  37.                     num++; // 1 2 1 2 3 4
  38.                 }
  39.                 num++; // 2
  40.             }
  41.             return num; // num = ?
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement