Loops Lists and Arrays in c#

This commit is contained in:
Geir Okkenhaug Jerstad 2024-11-18 12:56:05 +01:00
parent 2c097039f6
commit 06a6529881
12 changed files with 243 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}") = "ConsoleApp9", "ConsoleApp9\ConsoleApp9.csproj", "{91F6F93C-2FA7-4807-8CD0-8D479A1E1780}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91F6F93C-2FA7-4807-8CD0-8D479A1E1780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91F6F93C-2FA7-4807-8CD0-8D479A1E1780}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91F6F93C-2FA7-4807-8CD0-8D479A1E1780}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91F6F93C-2FA7-4807-8CD0-8D479A1E1780}.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,35 @@
namespace ConsoleApp9
{
class Loops
{
static void Main()
{
string[] args = new string[] { "dette", "er", "gøy" };
for (int i = 0; i < args.Length; i++)
{
Console.WriteLine(args[i]);
}
foreach (var arg in args)
{
Console.WriteLine(arg);
}
bool condition = true;
int i2 = 0;
while (condition)
{
if (i2 < 10)
{
Console.WriteLine("Hello world!");
i2++;
}
else
{
condition = false;
}
}
}
}
}