Skip to content
Snippets Groups Projects
Commit f3ccc48d authored by Uwe Wienkop's avatar Uwe Wienkop
Browse files

2020-06-08b

parent edadd871
Branches master
No related tags found
No related merge requests found
No preview for this file type
using System;
using System.Collections.Generic;
using System.Linq;
// Modifizieren/Erweitern Sie die KeyValue Klassen bzw. das Main()-Programm
// derart, dass Sie eine weitergehende Kalenderverwaltung realisieren. In
......@@ -45,6 +46,18 @@ namespace _07KeyValueList
public Termin(string was, string wer) { this.was = was; this.wer = wer; }
public override string ToString() => $"Termin: {was} mit {wer}";
}
class ComplexKey : IComparable<ComplexKey>
{
public int wert1;
public string wert2;
public int CompareTo(ComplexKey other)
{
int diff = wert1.CompareTo(other.wert1);
if (diff != 0)
return diff;
return wert2.CompareTo(other.wert2);
}
}
class Program
{
static void Main(string[] args)
......@@ -98,7 +111,16 @@ namespace _07KeyValueList
List<string> zutaten2;
List<string> zubereitung2;
(zutaten2, zubereitung2) = rezepte["Pfannkuchen"];
Console.WriteLine("Zutaten: ");
foreach (var item in zutaten2)
{
Console.WriteLine(item);
}
Console.WriteLine("Zubereitung:");
foreach (var item in zubereitung2)
{
Console.WriteLine(item);
}
//KeyValueListe<string, KeyValueListe<char, string>> l3 = new KeyValueListe<string, KeyValueListe<char, string>>();
//l3["Wienkop"]['A'] = "Teambesprechung";
......@@ -113,14 +135,20 @@ namespace _07KeyValueList
}
if ((2, 3, "2020").CompareTo((2, 3, "2020")) == 0)
Console.WriteLine("Ist gleich");
Console.WriteLine("Ist gleich"); // Ergebnis: die beiden sind gleich!
else
Console.WriteLine("Ist ungleich");
KeyValueListe<int, KeyValueListe<string, List<string>>> t3 = new KeyValueListe<int, KeyValueListe<string, List<string>>>();
t3[6]["Prog2"] = new List<string>();
t3[6]["Prog2"].Add("09.45 Vorlesung");
List<string> l;
t3[6]["Prog2"] = l = new List<string>();
l.Add("09.45 Vorlesung");
KeyValueListe<(int, int), string> t4 = new KeyValueListe<(int, int), string>();
t4[(3, 6)] = "Kaffestunde";
t4[(3, 5)] = "Vorlesung";
KeyValueListe<ComplexKey, string> t5 = new KeyValueListe<ComplexKey, string>();
}
}
}
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment