Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication3
  8. {
  9.     class Program
  10.     {
  11.         private static int zahl1, zahl2;
  12.         static void Main(string[] args)
  13.         {
  14.             while (true)
  15.             {
  16.                 Console.Write("Zahl 1: ");
  17.                 string eingabe1 = Console.ReadLine();
  18.  
  19.                 if (Int32.TryParse(eingabe1, out zahl1))
  20.                 {
  21.                     Console.Write("Zahl 2: ");
  22.                     string eingabe2 = Console.ReadLine();
  23.  
  24.                     if (Int32.TryParse(eingabe2, out zahl2))
  25.                     {
  26.                         Console.WriteLine("Summe: " + Summe(zahl1, zahl2));
  27.                     }
  28.                     else
  29.                     {
  30.                         Console.WriteLine("Keine gültige Zahl");
  31.                     }
  32.                 }
  33.                 else
  34.                 {
  35.                     Console.WriteLine("Keine gültige Zahl");
  36.                 }
  37.                 Console.ReadLine();
  38.                 Console.Clear();
  39.             }
  40.         }
  41.  
  42.         private static int Summe(int z1, int z2)
  43.         {
  44.             return z1 + z2;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement