diff --git a/Emne 3/Array-List/Array-List.sln b/Emne 3/Array-List/Array-List.sln new file mode 100644 index 0000000..cdd95cb --- /dev/null +++ b/Emne 3/Array-List/Array-List.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Array-List", "Array-List\Array-List.csproj", "{9ADAA04C-E4C0-4872-BF3B-B57CC9F5015D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9ADAA04C-E4C0-4872-BF3B-B57CC9F5015D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9ADAA04C-E4C0-4872-BF3B-B57CC9F5015D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9ADAA04C-E4C0-4872-BF3B-B57CC9F5015D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9ADAA04C-E4C0-4872-BF3B-B57CC9F5015D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/Array-List/Array-List/Array-List.csproj b/Emne 3/Array-List/Array-List/Array-List.csproj new file mode 100644 index 0000000..3bbf18b --- /dev/null +++ b/Emne 3/Array-List/Array-List/Array-List.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + Array_List + enable + enable + + + diff --git a/Emne 3/Array-List/Array-List/Program.cs b/Emne 3/Array-List/Array-List/Program.cs new file mode 100644 index 0000000..04c7fe6 --- /dev/null +++ b/Emne 3/Array-List/Array-List/Program.cs @@ -0,0 +1,28 @@ + +int[] numbers = new int[4]; + +numbers[0] = 1; +numbers[1] = 2; +numbers[2] = 3; +numbers[3] = 4; + +string[] _fourletterwords = + { + "WORD", "DATA", "CODE", "TEXT", "VIEW", "TASK", "FILE" + }; + + +List numbers2 = new List(); +numbers2.Add(1); +numbers2.Add(2); +numbers2.Add(3); +numbers2.Add(4); +void Run() +{ + Console.WriteLine(string.Join(' ',numbers)); + Console.WriteLine(string.Join('\t',_fourletterwords)); + Console.WriteLine(string.Join(',', numbers2)); + } + +Run(); + diff --git a/Emne 3/ConsoleApp9/ConsoleApp9.sln b/Emne 3/ConsoleApp9/ConsoleApp9.sln new file mode 100644 index 0000000..b28ae77 --- /dev/null +++ b/Emne 3/ConsoleApp9/ConsoleApp9.sln @@ -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 diff --git a/Emne 3/ConsoleApp9/ConsoleApp9/ConsoleApp9.csproj b/Emne 3/ConsoleApp9/ConsoleApp9/ConsoleApp9.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/ConsoleApp9/ConsoleApp9/ConsoleApp9.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/ConsoleApp9/ConsoleApp9/Program.cs b/Emne 3/ConsoleApp9/ConsoleApp9/Program.cs new file mode 100644 index 0000000..2d4f194 --- /dev/null +++ b/Emne 3/ConsoleApp9/ConsoleApp9/Program.cs @@ -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; + } + } + + } + } +} \ No newline at end of file diff --git a/Emne 3/Loops/Loops.sln b/Emne 3/Loops/Loops.sln new file mode 100644 index 0000000..4299da3 --- /dev/null +++ b/Emne 3/Loops/Loops.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Loops", "Loops\Loops.csproj", "{D268AFC9-15B1-49B4-89D0-F59F0B7FF5EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D268AFC9-15B1-49B4-89D0-F59F0B7FF5EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D268AFC9-15B1-49B4-89D0-F59F0B7FF5EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D268AFC9-15B1-49B4-89D0-F59F0B7FF5EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D268AFC9-15B1-49B4-89D0-F59F0B7FF5EF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/Loops/Loops/Loops.csproj b/Emne 3/Loops/Loops/Loops.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/Loops/Loops/Loops.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/Loops/Loops/Program.cs b/Emne 3/Loops/Loops/Program.cs new file mode 100644 index 0000000..17ebe2b --- /dev/null +++ b/Emne 3/Loops/Loops/Program.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; + +namespace Loops +{ + class Program + { + static void Main(string[] args) + { + WhileLoop(); + //DoWhileLoop(); + forEachLoop(); + ForLoop(); + } + // while + static void WhileLoop() + { + bool shouldRun = true; + int i = 0; + + while (shouldRun == true) + { + if (i >= 19) + { + shouldRun = false; + } + Console.WriteLine($"Hei verdi: {i}"); + i++; + } + } + + //do while + static void DoWhileLoop() + { + do + { + Console.WriteLine("Doing while..."); + } while (true); + } + + // foreach + static void forEachLoop() + { + int[] numberArray = {1,2,3,4,5,6,7,8,9,10}; + + foreach (var number in numberArray) + { + Console.WriteLine(number); + } + } + + // For loop + static void ForLoop() + { + for (int i = 0; i <= 20; i++) + { + Console.WriteLine($"For loop...{i}"); + } + } + } +} + diff --git a/Emne 3/Terminal-ui/Terminal-ui.sln b/Emne 3/Terminal-ui/Terminal-ui.sln new file mode 100644 index 0000000..74a7839 --- /dev/null +++ b/Emne 3/Terminal-ui/Terminal-ui.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terminal-ui", "Terminal-ui\Terminal-ui.csproj", "{F24C68E5-6740-4E86-94B9-94F522231E46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F24C68E5-6740-4E86-94B9-94F522231E46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F24C68E5-6740-4E86-94B9-94F522231E46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F24C68E5-6740-4E86-94B9-94F522231E46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F24C68E5-6740-4E86-94B9-94F522231E46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/Terminal-ui/Terminal-ui/Program.cs b/Emne 3/Terminal-ui/Terminal-ui/Program.cs new file mode 100644 index 0000000..36aac02 --- /dev/null +++ b/Emne 3/Terminal-ui/Terminal-ui/Program.cs @@ -0,0 +1,8 @@ +using System; +using Terminal.Gui; + + +Application.Run ().Dispose (); + +Application.shutdown (); + diff --git a/Emne 3/Terminal-ui/Terminal-ui/Terminal-ui.csproj b/Emne 3/Terminal-ui/Terminal-ui/Terminal-ui.csproj new file mode 100644 index 0000000..4191eb7 --- /dev/null +++ b/Emne 3/Terminal-ui/Terminal-ui/Terminal-ui.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Terminal_ui + enable + enable + + + + + + +