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,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

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>