Oppgaver Loops

This commit is contained in:
Geir Okkenhaug Jerstad 2024-11-18 13:04:45 +01:00
parent 06a6529881
commit 8a7cf65aa4
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}") = "LoopOppgave", "LoopOppgave\LoopOppgave.csproj", "{55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

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>

View file

@ -0,0 +1,41 @@
using System;
namespace LoopOppgave
{
class Program
{
static void Main()
{
Loops();
}
static void Loops()
{
// Oppgave 1
for (int i = 0; i <= 5; i++)
{
Console.WriteLine("Terje er kul");
}
// Oppgave 2
string sentence = "Terje er kul og hei verden fra foreach løkke";
foreach (var letter in sentence)
{
Console.WriteLine(letter);
}
// Oppgave 3
int number = 0;
while (number < 10)
{
Console.WriteLine($"Runde nummer... {number}");
number++;
}
}
}
}