ifElse
This commit is contained in:
parent
99e528e51e
commit
ddc33e2beb
|
@ -20,10 +20,16 @@
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ReturnNothing()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Denne metoden returnerer ingenting");
|
||||||
|
}
|
||||||
|
|
||||||
public static void Run()
|
public static void Run()
|
||||||
{
|
{
|
||||||
Console.WriteLine(sum());
|
Console.WriteLine(sum());
|
||||||
Console.WriteLine(Sum(9,5));
|
Console.WriteLine($"Summen av 9 og 5 er: {Sum(9,5)}");
|
||||||
|
ReturnNothing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
16
Emne 3/ConsoleApp4/ConsoleApp4.sln
Normal file
16
Emne 3/ConsoleApp4/ConsoleApp4.sln
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfElse", "IfElse\IfElse.csproj", "{ADAD2168-14E9-4D41-A651-74D0F952601F}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{ADAD2168-14E9-4D41-A651-74D0F952601F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ADAD2168-14E9-4D41-A651-74D0F952601F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ADAD2168-14E9-4D41-A651-74D0F952601F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ADAD2168-14E9-4D41-A651-74D0F952601F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
10
Emne 3/ConsoleApp4/IfElse/IfElse.csproj
Normal file
10
Emne 3/ConsoleApp4/IfElse/IfElse.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>
|
34
Emne 3/ConsoleApp4/IfElse/Program.cs
Normal file
34
Emne 3/ConsoleApp4/IfElse/Program.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
namespace CompareApp
|
||||||
|
{
|
||||||
|
class IsEqualOr
|
||||||
|
{
|
||||||
|
private static int num = 10;
|
||||||
|
private static int num2 = 10;
|
||||||
|
private static bool IsEqual = false;
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
if (num == num2)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Equal");
|
||||||
|
IsEqual = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Not Equal");
|
||||||
|
IsEqual = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsEqual)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
Console.WriteLine(num);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
num--;
|
||||||
|
Console.WriteLine(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue