Lister er fucked
This commit is contained in:
parent
03716695f9
commit
12c164c6b3
13 changed files with 157 additions and 26 deletions
16
Emne 3/ObjekterIListe/ObjekterIListe.sln
Normal file
16
Emne 3/ObjekterIListe/ObjekterIListe.sln
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObjekterIListe", "ObjekterIListe\ObjekterIListe.csproj", "{F05F887B-9700-40F0-BB06-7B90A67E1057}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F05F887B-9700-40F0-BB06-7B90A67E1057}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F05F887B-9700-40F0-BB06-7B90A67E1057}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F05F887B-9700-40F0-BB06-7B90A67E1057}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F05F887B-9700-40F0-BB06-7B90A67E1057}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
10
Emne 3/ObjekterIListe/ObjekterIListe/ObjekterIListe.csproj
Normal file
10
Emne 3/ObjekterIListe/ObjekterIListe/ObjekterIListe.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>
|
16
Emne 3/ObjekterIListe/ObjekterIListe/Person.cs
Normal file
16
Emne 3/ObjekterIListe/ObjekterIListe/Person.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
namespace ObjekterIListe;
|
||||
|
||||
public class Person
|
||||
{
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public int Age { get; set; }
|
||||
|
||||
// Constructor
|
||||
public Person(string firstName, string lastName, int Age)
|
||||
{
|
||||
firstName = firstName;
|
||||
lastName = lastName;
|
||||
Age = Age;
|
||||
}
|
||||
}
|
29
Emne 3/ObjekterIListe/ObjekterIListe/Program.cs
Normal file
29
Emne 3/ObjekterIListe/ObjekterIListe/Program.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
namespace ObjekterIListe
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static public void AddPeople()
|
||||
{
|
||||
List<Person> people = new List<Person>();
|
||||
Person person1 = new Person("Alice", "Smith", 25);
|
||||
Person person2 = new Person("Bob", "Jones", 37);
|
||||
Person person3 = new Person("Charlie", "Jones", 28);
|
||||
|
||||
people.Add(person1);
|
||||
people.Add(person2);
|
||||
people.Add(person3);
|
||||
WriteToConsole(people);
|
||||
|
||||
}
|
||||
static void WriteToConsole(this List<Person> people)
|
||||
{
|
||||
for (int i = 0; i < people.Count; i++)
|
||||
{
|
||||
Console.WriteLine($"Fornavn: {people[i].FirstName}\nEtternavn: {people[i].LastName}\nAlder: {people[i].Age}");
|
||||
}
|
||||
}
|
||||
static void Main(string[] args){
|
||||
AddPeople();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue