diff --git a/Emne 3/ConsoleApp7/ConsoleApp7.sln b/Emne 3/ConsoleApp7/ConsoleApp7.sln new file mode 100644 index 0000000..fece3f9 --- /dev/null +++ b/Emne 3/ConsoleApp7/ConsoleApp7.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Switch", "Switch\Switch.csproj", "{9BB73868-DE61-4C45-B4AE-727845B52ABA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9BB73868-DE61-4C45-B4AE-727845B52ABA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BB73868-DE61-4C45-B4AE-727845B52ABA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BB73868-DE61-4C45-B4AE-727845B52ABA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BB73868-DE61-4C45-B4AE-727845B52ABA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/ConsoleApp7/Switch/Program.cs b/Emne 3/ConsoleApp7/Switch/Program.cs new file mode 100644 index 0000000..bd20a03 --- /dev/null +++ b/Emne 3/ConsoleApp7/Switch/Program.cs @@ -0,0 +1,41 @@ +namespace Switch +{ + class SwitchTest + { + public static void numberSwitch() + { + Console.WriteLine("Please enter a number: "); + var number = Console.ReadLine(); + + var result = number switch + { + "1" => "Wrong number", + "2" => "Wrong number", + "3" => "Right number", + _ => "unkown input", + }; + Console.WriteLine($"{result}"); + } + public static void Main(String[] args) + { + var menuChoice = Console.ReadLine(); + switch (menuChoice) + { + case "1": + Console.WriteLine("Switch 1"); + break; + case "2": + Console.WriteLine("Switch 2"); + break; + case "3": + Console.WriteLine("Switch 3"); + break; + default: + Console.WriteLine("Invalid choice"); + numberSwitch(); + break; + } + } + } +} + diff --git a/Emne 3/ConsoleApp7/Switch/Switch.csproj b/Emne 3/ConsoleApp7/Switch/Switch.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/ConsoleApp7/Switch/Switch.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + +