switchTest
This commit is contained in:
parent
3df0f671b8
commit
15bf38744f
16
Emne 3/ConsoleApp7/ConsoleApp7.sln
Normal file
16
Emne 3/ConsoleApp7/ConsoleApp7.sln
Normal 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
|
41
Emne 3/ConsoleApp7/Switch/Program.cs
Normal file
41
Emne 3/ConsoleApp7/Switch/Program.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
10
Emne 3/ConsoleApp7/Switch/Switch.csproj
Normal file
10
Emne 3/ConsoleApp7/Switch/Switch.csproj
Normal 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>
|
Loading…
Reference in a new issue