Difference between revisions of "C Sharp"
From Teknologisk videncenter
Line 15: | Line 15: | ||
static void Main(string[] args) | static void Main(string[] args) | ||
{ | { | ||
− | |||
string ope = Console.ReadLine(); | string ope = Console.ReadLine(); | ||
Line 24: | Line 23: | ||
else | else | ||
{ Console.WriteLine("det var ikke en gyldig operator"); } | { Console.WriteLine("det var ikke en gyldig operator"); } | ||
− | + | ||
− | |||
− | |||
Console.ReadLine(); | Console.ReadLine(); | ||
} | } | ||
− | + | ||
static void Plus() | static void Plus() | ||
{ | { | ||
Line 36: | Line 33: | ||
Console.WriteLine(tal1 + tal2); | Console.WriteLine(tal1 + tal2); | ||
} | } | ||
− | + | ||
static void minus() | static void minus() | ||
{ | { |
Revision as of 15:27, 5 December 2016
Kode eksempler - Gentelman klub
Console.WriteLine("Skriv din alder"); string alder = Console.ReadLine(); int age; age = Convert.ToInt32(alder); if (((age > 20) && (age < 80)) || age != 21) { Console.WriteLine("Velkommen!"); } else { Console.WriteLine("gå hjem og spil OverWatch"); } Console.ReadLine();
static void Main(string[] args) { string ope = Console.ReadLine();
if (ope == "+") { Plus(); } else if (ope == "-") { minus(); } else { Console.WriteLine("det var ikke en gyldig operator"); } Console.ReadLine(); } static void Plus() { int tal1 = Convert.ToInt32(Console.ReadLine()); int tal2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(tal1 + tal2); } static void minus() { int tal1 = Convert.ToInt32(Console.ReadLine()); int tal2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(tal1 - tal2); }