This commit is contained in:
Geir Okkenhaug Jerstad 2024-11-14 14:08:38 +01:00
parent ddc33e2beb
commit 95d3a2be13
4 changed files with 82 additions and 1 deletions

View file

@ -6,6 +6,13 @@
private static int num2 = 10;
private static bool IsEqual = false;
static void Main(string[] args)
{
Compare();
UnEqual(5, 5);
IsThirty(25, 5);
}
static void Compare()
{
if (num == num2)
{
@ -17,7 +24,7 @@
Console.WriteLine("Not Equal");
IsEqual = false;
}
if (IsEqual)
{
num++;
@ -29,6 +36,30 @@
Console.WriteLine(num);
}
}
static int UnEqual(int num1, int num2)
{
if (num1 != num2)
{
return num1 + num2;
}
else
{
return num1 * num2;
}
}
static bool IsThirty(int num, int num2)
{
if (num + num2 == 30)
{
return true;
}
else
{
return false;
}
}
}
}

View file

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Random", "Random\Random.csproj", "{94A6C03C-25AE-4D33-97EB-E732F895D396}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{94A6C03C-25AE-4D33-97EB-E732F895D396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94A6C03C-25AE-4D33-97EB-E732F895D396}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94A6C03C-25AE-4D33-97EB-E732F895D396}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94A6C03C-25AE-4D33-97EB-E732F895D396}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,24 @@
using System;
namespace Random
{
class Random
{
static void Main(string[] args)
{
System.Random rnd = new System.Random();
int randomnr = rnd.Next(0, 3);
if (randomnr == 0)
{
Console.WriteLine("Tallet ble 0");
}else if (randomnr == 1)
{
Console.WriteLine("Tallet ble 1");
}
else
{
Console.WriteLine("Tallet ble 2");
}
}
}
}

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>