switchTest

This commit is contained in:
Geir Okkenhaug Jerstad 2024-11-15 10:47:37 +01:00
parent 3df0f671b8
commit 15bf38744f
3 changed files with 67 additions and 0 deletions

View file

@ -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;
}
}
}
}

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>