erweiterung
This commit is contained in:
41
BeispielCesaChiffre/Alphabet.cs
Normal file
41
BeispielCesaChiffre/Alphabet.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace BeispielCesaChiffre
|
||||
{
|
||||
public class Alphabet
|
||||
{
|
||||
//Ein Array welches das Alphabet in Großbuchstaben darstellt
|
||||
//Jeder Grp0buchstabe hat eine Indexnummer
|
||||
//Position eines Großbuchstabens im tatsächlichen Alphabet ist Indexnummer +1
|
||||
private char[] alphabet = new[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
|
||||
/// <summary>
|
||||
/// Gibt die Position eines Großgeschreibenen Buchstanbens (ASCII) im tatsächlichen Alphabet zurück
|
||||
/// </summary>
|
||||
/// <param name="x">Großgeschreibener Character</param>
|
||||
/// <returns>Position im Alphabet</returns>
|
||||
public int PositionImTatsächlichenAlphabetLokalisieren(char x)
|
||||
{
|
||||
for (int i = 0; i < alphabet.Length; i++)
|
||||
{
|
||||
if (x == alphabet[i])
|
||||
{
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public char GetBuchstabenDerPositionImTatsächlichemAlphabet(int x)
|
||||
{
|
||||
if (x == 0)
|
||||
{
|
||||
return this.alphabet[x];
|
||||
}
|
||||
return this.alphabet[x - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielCesaChiffre/BeispielCesaChiffre.csproj
Normal file
10
BeispielCesaChiffre/BeispielCesaChiffre.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
43
BeispielCesaChiffre/CaeserMaschine.cs
Normal file
43
BeispielCesaChiffre/CaeserMaschine.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielCesaChiffre
|
||||
{
|
||||
internal class CaeserMaschine
|
||||
{
|
||||
//Um die Werte vom User zu holen (Klartext & Verscheibung)
|
||||
private UserEingabe usereingabe = new UserEingabe();
|
||||
//Um aus Zahlen Buchstaben zu machen und umgekert
|
||||
private Alphabet alphabet = new Alphabet();
|
||||
public void Verschlüsseln()
|
||||
{
|
||||
//Daten vom User holen
|
||||
this.usereingabe.SetKlartext();
|
||||
this.usereingabe.SetVerscheibung();
|
||||
|
||||
char[] klartextChars = this.usereingabe.GetKlartext().ToCharArray();
|
||||
char[] verschlüsselteChars = new char[klartextChars.Length];
|
||||
int verschiebung = this.usereingabe.GetVerscheibung();
|
||||
|
||||
for (int i = 0; i < klartextChars.Length; i++)
|
||||
{
|
||||
int[] klartextInts = new int[klartextChars.Length];
|
||||
int[] verschlüsseltInts = new int[klartextChars.Length];
|
||||
klartextInts[i] = this.alphabet.PositionImTatsächlichenAlphabetLokalisieren(klartextChars[i]);
|
||||
|
||||
verschlüsseltInts[i] = klartextInts[i] + verschiebung;
|
||||
verschlüsseltInts[i] = verschlüsseltInts[i] % 52;
|
||||
if (verschlüsseltInts[i] == 0)
|
||||
{
|
||||
verschlüsseltInts[i] = 52;
|
||||
}
|
||||
verschlüsselteChars[i] = this.alphabet.GetBuchstabenDerPositionImTatsächlichemAlphabet(verschlüsseltInts[i]);
|
||||
}
|
||||
string s = new string(verschlüsselteChars);
|
||||
Console.WriteLine(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
BeispielCesaChiffre/Program.cs
Normal file
33
BeispielCesaChiffre/Program.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Threading.Channels;
|
||||
|
||||
namespace BeispielCesaChiffre
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Console.WriteLine("Hello Wolrd");
|
||||
//Beispiel Ceasar-Verschlüsselung
|
||||
//Klartext Alphabet: ABDCEFGHIJKLMNOPQRSTUVFXYZ
|
||||
//Um wieviel Stellen word verrückt: 3
|
||||
//Verschlüsseltes Alphabet: DEFGHIJKLMNOPQRSTUVWXYZABC
|
||||
//A B D C E F G H I J K L M N O P Q R S T U V W X Y Z
|
||||
//D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
|
||||
|
||||
//Klartext: HALLOWELT
|
||||
//Verschlüsselt: KDOORZHOW
|
||||
//Klartext: HALLOWELT
|
||||
|
||||
//klartext: Fisch
|
||||
//Verschlüsselt: ILVGK
|
||||
//Klartext: FISCH
|
||||
|
||||
//Klartext: Computer
|
||||
//Verschlüsselt: GRPSXWHU
|
||||
//Klartext: COMPUTER
|
||||
|
||||
CaeserMaschine caeserMaschine = new CaeserMaschine();
|
||||
caeserMaschine.Verschlüsseln();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
BeispielCesaChiffre/UserEingabe.cs
Normal file
35
BeispielCesaChiffre/UserEingabe.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielCesaChiffre
|
||||
{
|
||||
public class UserEingabe
|
||||
{
|
||||
private int verschiebung;
|
||||
private string? klartext;
|
||||
|
||||
public void SetVerscheibung()
|
||||
{
|
||||
Console.WriteLine("Um wievile Positionen soll das Alphabet verschoben werden?");
|
||||
string? eingabe = Console.ReadLine();
|
||||
this.verschiebung = Convert.ToInt32(eingabe);
|
||||
}
|
||||
public void SetKlartext()
|
||||
{
|
||||
Console.WriteLine("Welchen text wollen Sie verschlüsseln?");
|
||||
string? eingabe = Console.ReadLine();
|
||||
this.klartext = eingabe;
|
||||
}
|
||||
public int GetVerscheibung()
|
||||
{
|
||||
return this.verschiebung;
|
||||
}
|
||||
public string? GetKlartext()
|
||||
{
|
||||
return this.klartext;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielContainer3/BeispielContainer3.csproj
Normal file
10
BeispielContainer3/BeispielContainer3.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
57
BeispielContainer3/Program.cs
Normal file
57
BeispielContainer3/Program.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
namespace BeispielContainer3
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string text = "15;D;Peter Schmidt;Wuppertal\n"
|
||||
+ "17;D;Hans Meier;Düsseldorf\n"
|
||||
+ "23;E;Regina Schulz;Mettmann\n"
|
||||
+ "31;D;Kathrin Müller;Erkrath\n"
|
||||
+ "32;E;Rudolf Kramer;Witten\n"
|
||||
+ "35;E;Anne Kunze;Bremen";
|
||||
string[] datensatz = text.Split('\n');
|
||||
string[] buchungsID = new string[datensatz.Length];
|
||||
string[] zimmer = new string[datensatz.Length];
|
||||
string[] vorname = new string[datensatz.Length];
|
||||
string[] nachname = new string[datensatz.Length];
|
||||
string[] wohnort = new string[datensatz.Length];
|
||||
for (int i = 0; i < datensatz.Length; i++)
|
||||
{
|
||||
buchungsID[i] = datensatz[i].Split(';')[0];
|
||||
zimmer[i] = datensatz[i].Split(";")[1].Replace("D", "Doppelzimmer").Replace("E", "Einzelzimmer");
|
||||
vorname[i] = datensatz[i].Split(";")[2].Split(" ")[0];
|
||||
nachname[i] = datensatz[i].Split(";")[2].Split(" ")[1];
|
||||
wohnort[i] = datensatz[i].Split(";")[3];
|
||||
}
|
||||
for (int i = 0; i < datensatz.Length; i++)
|
||||
{
|
||||
Console.WriteLine("Zimmer: " + buchungsID[i]);
|
||||
Console.WriteLine(" " + zimmer[i]);
|
||||
Console.WriteLine("Vorname: " + vorname[i]);
|
||||
Console.WriteLine("Nachname: " + nachname[i]);
|
||||
Console.WriteLine("Wohnort: " + wohnort[i]);
|
||||
Console.WriteLine();
|
||||
}
|
||||
List<Dictionary<string, string>> hotelZimmerBuchungsListe = new List<Dictionary<string, string>>();
|
||||
for (int i = 0; i < buchungsID.Length; i++)
|
||||
{
|
||||
Dictionary<string, string> bookingList = new Dictionary<string, string>();
|
||||
bookingList.Add("Zimmer: ", buchungsID[i]);
|
||||
bookingList.Add(" ", zimmer[i]);
|
||||
bookingList.Add("Vorname: ", vorname[i]);
|
||||
bookingList.Add("Nachname: ", nachname[i]);
|
||||
bookingList.Add("Wohnort: ", wohnort[i]);
|
||||
hotelZimmerBuchungsListe.Add(bookingList);
|
||||
}
|
||||
foreach (var bookinglist in hotelZimmerBuchungsListe)
|
||||
{
|
||||
foreach (var item2 in bookinglist)
|
||||
{
|
||||
Console.WriteLine(item2.Key + " " + item2.Value);
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielContainer4/BeispielContainer4.csproj
Normal file
10
BeispielContainer4/BeispielContainer4.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
61
BeispielContainer4/Program.cs
Normal file
61
BeispielContainer4/Program.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
namespace BeispielContainer3
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string text = "15;D;Peter Schmidt;Wuppertal\n"
|
||||
+ "17;D;Hans Meier;Düsseldorf\n"
|
||||
+ "23;E;Regina Schulz;Mettmann\n"
|
||||
+ "31;D;Kathrin Müller;Erkrath\n"
|
||||
+ "32;E;Rudolf Kramer;Witten\n"
|
||||
+ "35;E;Anne Kunze;Bremen";
|
||||
string[] datensatz = text.Split('\n');
|
||||
string[] buchungsID = new string[datensatz.Length];
|
||||
string[] zimmer = new string[datensatz.Length];
|
||||
string[] vorname = new string[datensatz.Length];
|
||||
string[] nachname = new string[datensatz.Length];
|
||||
string[] wohnort = new string[datensatz.Length];
|
||||
for (int i = 0; i < datensatz.Length; i++)
|
||||
{
|
||||
buchungsID[i] = datensatz[i].Split(';')[0];
|
||||
zimmer[i] = datensatz[i].Split(";")[1].Replace("D", "Doppelzimmer").Replace("E", "Einzelzimmer");
|
||||
vorname[i] = datensatz[i].Split(";")[2].Split(" ")[0];
|
||||
nachname[i] = datensatz[i].Split(";")[2].Split(" ")[1];
|
||||
wohnort[i] = datensatz[i].Split(";")[3];
|
||||
}
|
||||
/*
|
||||
for (int i = 0; i < datensatz.Length; i++)
|
||||
{
|
||||
Console.WriteLine("Zimmer: " + buchungsID[i]);
|
||||
Console.WriteLine(" " + zimmer[i]);
|
||||
Console.WriteLine("Vorname: " + vorname[i]);
|
||||
Console.WriteLine("Nachname: " + nachname[i]);
|
||||
Console.WriteLine("Wohnort: " + wohnort[i]);
|
||||
Console.WriteLine();
|
||||
}
|
||||
*/
|
||||
List<Dictionary<string, string>> hotelZimmerBuchungsListe = new List<Dictionary<string, string>>();
|
||||
for (int i = 0; i < buchungsID.Length; i++)
|
||||
{
|
||||
Dictionary<string, string> bookingList = new Dictionary<string, string>();
|
||||
|
||||
bookingList.Add("Zimmer: ", buchungsID[i]);
|
||||
bookingList.Add(" ", zimmer[i]);
|
||||
bookingList.Add("Vorname: ", vorname[i]);
|
||||
bookingList.Add("Nachname: ", nachname[i]);
|
||||
bookingList.Add("Wohnort: ", wohnort[i]);
|
||||
hotelZimmerBuchungsListe.Add(bookingList);
|
||||
|
||||
}
|
||||
foreach (var bookinglist in hotelZimmerBuchungsListe)
|
||||
{
|
||||
foreach (var item2 in bookinglist)
|
||||
{
|
||||
Console.WriteLine(item2.Key + " " + item2.Value);
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielExceptions/BeispielExceptions.csproj
Normal file
10
BeispielExceptions/BeispielExceptions.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
72
BeispielExceptions/Program.cs
Normal file
72
BeispielExceptions/Program.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace BeispielExceptions
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
bool fehler = true;
|
||||
do
|
||||
{
|
||||
decimal zahl1 = InputInt2("Erste Zahl: ");
|
||||
decimal zahl2 = InputInt2("Zweite Zahl: ");
|
||||
if (zahl2 != 0)
|
||||
{
|
||||
//double erg;
|
||||
//bool ok = Division(zahl1, zahl2, out erg);
|
||||
Console.WriteLine(zahl1 / zahl2);
|
||||
fehler = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Die zweite Zahl darf nicht 0 sein!");
|
||||
}
|
||||
}
|
||||
while (fehler);
|
||||
}
|
||||
static decimal InputInt(string text)
|
||||
{
|
||||
decimal input = 0;
|
||||
bool fehler = true;
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.Write(text);
|
||||
input = decimal.Parse(Console.ReadLine());
|
||||
fehler = false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine($"Nochmal, du Honk!");
|
||||
}
|
||||
|
||||
}
|
||||
while (fehler);
|
||||
return input;
|
||||
}
|
||||
static decimal InputInt2(string text)
|
||||
{
|
||||
decimal input;
|
||||
bool ok;
|
||||
do
|
||||
{
|
||||
Console.Write(text);
|
||||
ok = decimal.TryParse(Console.ReadLine(), out input);
|
||||
}
|
||||
while (!ok);
|
||||
return input;
|
||||
}
|
||||
//static bool Division(decimal z1, decimal z2, out decimal erg)
|
||||
//{
|
||||
// if (z2 != 0)
|
||||
// {
|
||||
// erg = z1 / z2;
|
||||
// return true;
|
||||
// }
|
||||
// erg = 0;
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
}
|
||||
10
BeispielExceptions2/BeispielExceptions2.csproj
Normal file
10
BeispielExceptions2/BeispielExceptions2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
25
BeispielExceptions2/Program.cs
Normal file
25
BeispielExceptions2/Program.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace BeispielExceptions2
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string[] strings = {"abc","def","ghi","jkl","mno","qpr","stu" };
|
||||
PrintString(strings, 11);
|
||||
}
|
||||
/// <summary>
|
||||
/// Eine lustig Zusammenfassung
|
||||
/// </summary>
|
||||
/// <param name="array"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
static void PrintString(string[] array, int position)
|
||||
{
|
||||
if (position < 0 || position > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(position), position, "Außerhalb des Arrays");
|
||||
}
|
||||
Console.WriteLine(array[position]);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielGenerischeTypen/BeispielGenerischeTypen.csproj
Normal file
10
BeispielGenerischeTypen/BeispielGenerischeTypen.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
14
BeispielGenerischeTypen/IKarten.cs
Normal file
14
BeispielGenerischeTypen/IKarten.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielGenerischeTypen
|
||||
{
|
||||
public interface IKarte
|
||||
{
|
||||
string Farbe { get; }
|
||||
string Wert { get; }
|
||||
}
|
||||
}
|
||||
22
BeispielGenerischeTypen/Karte.cs
Normal file
22
BeispielGenerischeTypen/Karte.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielGenerischeTypen
|
||||
{
|
||||
|
||||
public class Karte : IKarte
|
||||
{
|
||||
public string Farbe { get; }
|
||||
public string Wert { get; }
|
||||
|
||||
public Karte(string farbe, string wert)
|
||||
{
|
||||
Farbe = farbe;
|
||||
Wert = wert;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
17
BeispielGenerischeTypen/Program.cs
Normal file
17
BeispielGenerischeTypen/Program.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace BeispielGenerischeTypen
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Stapel<Karte> stapel = new Stapel<Karte>();
|
||||
Karte karte1 = new Karte("Herz", "König");
|
||||
Karte karte2 = new Karte("Pik", "Ass");
|
||||
stapel.Push(karte1);
|
||||
stapel.Push(karte2);
|
||||
Console.WriteLine(stapel.Pop().Wert);
|
||||
Console.WriteLine(stapel.Pop().Wert);
|
||||
Console.WriteLine(stapel.IsEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
43
BeispielGenerischeTypen/Stapel.cs
Normal file
43
BeispielGenerischeTypen/Stapel.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielGenerischeTypen
|
||||
{
|
||||
|
||||
public class Stapel<T> where T : IKarte
|
||||
{
|
||||
private List<T> karten;
|
||||
|
||||
public Stapel()
|
||||
{
|
||||
karten = new List<T>();
|
||||
}
|
||||
|
||||
public void Push(T karte)
|
||||
{
|
||||
karten.Add(karte);
|
||||
}
|
||||
|
||||
public T Pop()
|
||||
{
|
||||
if (karten.Count == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Der Stapel ist leer.");
|
||||
}
|
||||
|
||||
int lastIndex = karten.Count - 1;
|
||||
T karte = karten[lastIndex];
|
||||
karten.RemoveAt(lastIndex);
|
||||
return karte;
|
||||
}
|
||||
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return karten.Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
10
BeispielInterface2/BeispielInterface2.csproj
Normal file
10
BeispielInterface2/BeispielInterface2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
19
BeispielInterface2/DataBaseLogger.cs
Normal file
19
BeispielInterface2/DataBaseLogger.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace BeispielInterface2
|
||||
{
|
||||
internal class DataBaseLogger : ILogger
|
||||
{
|
||||
public void LogData(string text)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine($"Der Text \"{text}\" wird in die Datenbank gespeicher");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
BeispielInterface2/FileLogger.cs
Normal file
18
BeispielInterface2/FileLogger.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielInterface2
|
||||
{
|
||||
internal class FileLogger : ILogger
|
||||
{
|
||||
public void LogData(string text)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"Der Text \"{text}\" wird in der Datei gespeicher");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
BeispielInterface2/ILogger.cs
Normal file
16
BeispielInterface2/ILogger.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielInterface2
|
||||
{
|
||||
interface ILogger
|
||||
{
|
||||
public void LogData(string text)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
BeispielInterface2/Program.cs
Normal file
18
BeispielInterface2/Program.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace BeispielInterface2
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
MethodeProgrammablauf(new FileLogger());
|
||||
MethodeProgrammablauf(new DataBaseLogger());
|
||||
}
|
||||
static void MethodeProgrammablauf(ILogger logger)
|
||||
{
|
||||
Console.WriteLine("Die Methode macht aufregende Ding....");
|
||||
Console.WriteLine("Zwischendurch muss Sie Dinge Loggen.");
|
||||
logger.LogData("Wichtige Infos");
|
||||
Console.WriteLine("Und weitere aufgende Dinge Passieren....");
|
||||
}
|
||||
}
|
||||
}
|
||||
20
BeispielInterfaces/AmphibienFahrzeug.cs
Normal file
20
BeispielInterfaces/AmphibienFahrzeug.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielInterfaces
|
||||
{
|
||||
internal class AmphibienFahrzeug : IFahren, ISchwimmen
|
||||
{
|
||||
public void Fahren()
|
||||
{
|
||||
Console.WriteLine("Das Amphibienfahrzeug fährt.");
|
||||
}
|
||||
public void Schwimmen()
|
||||
{
|
||||
Console.WriteLine("Das Amphibienfahrzeug schwimmt.");
|
||||
}
|
||||
}
|
||||
}
|
||||
17
BeispielInterfaces/Auto.cs
Normal file
17
BeispielInterfaces/Auto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielInterfaces
|
||||
{
|
||||
internal class Auto : IFahren
|
||||
{
|
||||
public void Fahren()
|
||||
{
|
||||
Console.WriteLine("Das Auto fährt");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
BeispielInterfaces/BeispielInterfaces.csproj
Normal file
10
BeispielInterfaces/BeispielInterfaces.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
16
BeispielInterfaces/Boot.cs
Normal file
16
BeispielInterfaces/Boot.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielInterfaces
|
||||
{
|
||||
internal class Boot : ISchwimmen
|
||||
{
|
||||
public void Schwimmen()
|
||||
{
|
||||
Console.WriteLine("Das Boot schwimmt.");
|
||||
}
|
||||
}
|
||||
}
|
||||
13
BeispielInterfaces/IFahren.cs
Normal file
13
BeispielInterfaces/IFahren.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielInterfaces
|
||||
{
|
||||
interface IFahren
|
||||
{
|
||||
public void Fahren();
|
||||
}
|
||||
}
|
||||
13
BeispielInterfaces/ISchwimmen.cs
Normal file
13
BeispielInterfaces/ISchwimmen.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielInterfaces
|
||||
{
|
||||
interface ISchwimmen
|
||||
{
|
||||
public void Schwimmen();
|
||||
}
|
||||
}
|
||||
16
BeispielInterfaces/Program.cs
Normal file
16
BeispielInterfaces/Program.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace BeispielInterfaces
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
IrgendwasMitFahren(new Auto());
|
||||
IrgendwasMitFahren(new AmphibienFahrzeug());
|
||||
}
|
||||
static void IrgendwasMitFahren(IFahren fahren)
|
||||
{
|
||||
Console.WriteLine("Diese Mehtode benötigt etwas das fahren kann.");
|
||||
fahren.Fahren();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BeispielRekusion/BeispielRekusion.csproj
Normal file
10
BeispielRekusion/BeispielRekusion.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
33
BeispielRekusion/Program.cs
Normal file
33
BeispielRekusion/Program.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
namespace BeispielRekusion
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(FatultaetRekursiv(16062));
|
||||
}
|
||||
static long FakultaetIterativ(int n)
|
||||
{
|
||||
long ergebnis = 1;
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
ergebnis = ergebnis * i;
|
||||
}
|
||||
return ergebnis;
|
||||
}
|
||||
static ulong FatultaetRekursiv(ulong n)
|
||||
{
|
||||
if (n == 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n * FatultaetRekursiv(n-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
BesispielDatenTypString/BesispielDatenTypString.csproj
Normal file
10
BesispielDatenTypString/BesispielDatenTypString.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
96
BesispielDatenTypString/Program.cs
Normal file
96
BesispielDatenTypString/Program.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
namespace BesispielDatenTypString
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
/*
|
||||
Was ist ein String
|
||||
|
||||
=> die repräsentation einer sequentiellen Auflistung von chars,
|
||||
ein char = 1 UTF-16-Zeichen
|
||||
|
||||
Die maximale Größe eines Strings ist ca. 2GB (1 Milliarde Zeichen)
|
||||
|
||||
immutable => nicht veränderbar
|
||||
wenn Sie einen string verändern, dann erschaffen Sie in Wahrheit einen neuen,
|
||||
und der alte bleibt im Speicher vorhanden.
|
||||
|
||||
Wie können Strings erzeugt werden?
|
||||
literal
|
||||
*/
|
||||
string myString = "Hello World";
|
||||
// Kostruktor
|
||||
string myString2 = new string('*', 10);
|
||||
Console.WriteLine(myString2);
|
||||
// durch char-arrays
|
||||
char[] charArray = { 'H', 'e', 'l', 'l', 'o' };
|
||||
string myString3 = new string(charArray);
|
||||
// was kann mir die Klasse String erzählen?
|
||||
// die länge
|
||||
int x = myString.Length;
|
||||
// die einzelnen Chars
|
||||
char meinE = myString3[1];
|
||||
Console.WriteLine(meinE);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Vergleichen von Strings
|
||||
Console.WriteLine(myString3.Equals("Hello"));
|
||||
Console.WriteLine(myString3.Equals("Hella"));
|
||||
// Womit der String beginnt
|
||||
myString3.StartsWith('H');
|
||||
myString3.StartsWith("Hell");
|
||||
// Womit der String endet
|
||||
myString3.EndsWith('o');
|
||||
myString3.EndsWith("lo");
|
||||
// Wo eine Zeichenkette beginnt
|
||||
string myString4 = "Ein Ring Sie alle zu knechten, ins Dunkel zu treiben und ewig zu binden";
|
||||
Console.WriteLine(myString4.IndexOf("Ring")); // erster Treffer
|
||||
Console.WriteLine(myString4.LastIndexOf("Ring")); // letzter Treffer
|
||||
Console.WriteLine(myString4.Substring(4));
|
||||
|
||||
Console.WriteLine(myString4.CompareTo(
|
||||
"Fin Ring Sie alle zu knechten, " +
|
||||
"ins Dunkel zu Treiben und ewig zu Ring Binden"));
|
||||
Console.WriteLine(myString4.CompareTo(
|
||||
"Ain Ring Sie alle zu knechten, " +
|
||||
"ins Dunkel zu Treiben und ewig zu Ring binden"));
|
||||
Console.WriteLine(myString4.CompareTo(
|
||||
"Ein Ring Sie alle zu knechten, " +
|
||||
"ins Dunkel zu Treiben und ewig zu Ring binden"));
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Kombinieren
|
||||
myString4.Substring(myString4.IndexOf("Ring"));
|
||||
// CompareTo
|
||||
// Werte werden Index für Index verglichen, keine unterschiede = 0
|
||||
// WertA == WertB = 0
|
||||
// WertA > WertB = 1
|
||||
// WertA < WertB = -1
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Strings manipulieren
|
||||
//Trim
|
||||
string myString5 = "****Hallo*****";
|
||||
Console.WriteLine(myString5.Trim('*')); //=> Hello World
|
||||
Console.WriteLine(myString5.Trim('*'));
|
||||
//TrimStart || TrimEnd => Trim macht beides
|
||||
|
||||
//PadLeft || PadRight
|
||||
string myString6 = "Stuhl";
|
||||
Console.WriteLine(myString6.PadLeft(myString6.Length + 2, '*'));
|
||||
Console.WriteLine(myString6.PadLeft(myString6.Length + 2));
|
||||
Console.WriteLine(myString6.PadRight(myString6.Length + 2, '*'));
|
||||
Console.WriteLine(myString6.PadRight(myString6.Length + 2));
|
||||
|
||||
//Insert
|
||||
string mystring7 = "Ich habe meinen verloren";
|
||||
mystring7 = mystring7.Insert(16, "Schlüssel ");
|
||||
Console.WriteLine(mystring7);
|
||||
//Remove
|
||||
mystring7 = mystring7.Remove(26);
|
||||
Console.WriteLine(mystring7);
|
||||
mystring7 = mystring7.Remove(0, 16);
|
||||
Console.WriteLine(mystring7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
ContainerBeispiel/ContainerBeispiel.csproj
Normal file
10
ContainerBeispiel/ContainerBeispiel.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
54
ContainerBeispiel/Program.cs
Normal file
54
ContainerBeispiel/Program.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
namespace ContainerBeispiel
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Datenbeschaffung = Beispielexemplar einer formatierung Datei
|
||||
string daten = "123; Hammer, Dübel, Nägel\n223; Fischfutter, Sand, Schlauch\n434; Pfanne, Gabel\n001; Apfel, Flasche, Tisch\n727; Laptop, Kabel, Tapete";
|
||||
//Console.WriteLine(daten);
|
||||
//Console.WriteLine("Datensätze erstellen: ");
|
||||
string[] datensätze = daten.Split('\n');
|
||||
//foreach (string item in datensätze)
|
||||
//{
|
||||
// Console.WriteLine(item);
|
||||
//}
|
||||
//Console.WriteLine("Keys von Values Trennen: ");
|
||||
string[] Schlüssel = new string[datensätze.Length];
|
||||
string[] Werte = new string[datensätze.Length];
|
||||
for (int i = 0; i < datensätze.Length -1; i++)
|
||||
{
|
||||
//Console.WriteLine(i);
|
||||
Schlüssel[i] = datensätze[i].Split(";")[0];
|
||||
//Console.WriteLine(Schlüssel[i]);
|
||||
Werte[i] = datensätze[i].Split(";")[1];
|
||||
//Console.WriteLine(Werte[i]);
|
||||
}
|
||||
//Console.WriteLine("Die isolierten Schlüssel");
|
||||
//foreach (var item in Schlüssel)
|
||||
//{
|
||||
// Console.WriteLine(item);
|
||||
//}
|
||||
//Console.WriteLine("Die islolierten Werte");
|
||||
//foreach (var item in Werte)
|
||||
//{
|
||||
// Console.WriteLine(item);
|
||||
//}
|
||||
Console.WriteLine("Dictronary<string ,List<string>> erstellen und füllen");
|
||||
Dictionary<string, List<string>> kundennummerZuWare = new Dictionary<string, List<string>>();
|
||||
for (int i = 0; i < Schlüssel.Length-1; i++)
|
||||
{
|
||||
string[] einzelneWerte = Werte[i].Split(",");
|
||||
kundennummerZuWare.Add(Schlüssel[i], einzelneWerte.ToList());
|
||||
}
|
||||
foreach (var item in kundennummerZuWare)
|
||||
{
|
||||
Console.WriteLine(item.Key);
|
||||
foreach (var item2 in item.Value)
|
||||
{
|
||||
Console.WriteLine("-" + item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
ContainerBeispiel2/ContainerBeispiel2.csproj
Normal file
10
ContainerBeispiel2/ContainerBeispiel2.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
162
ContainerBeispiel2/Program.cs
Normal file
162
ContainerBeispiel2/Program.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
using System.Data;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace ContainerBeispiel2
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//string daten = "123; Hammer, Dübel, Nägel\n223; Fischfutter, Sand, Schlauch\n434; Pfanne, Gabel\n001; Apfel, Flasche, Tisch\n727; Laptop, Kabel, Tapete";
|
||||
//string[] datensätze = daten.Split('\n');
|
||||
//string[] Schlüssel = new string[datensätze.Length];
|
||||
//string[] Werte = new string[datensätze.Length];
|
||||
//for (int i = 0; i < datensätze.Length - 1; i++)
|
||||
//{
|
||||
// Schlüssel[i] = datensätze[i].Split(";")[0];
|
||||
// Werte[i] = datensätze[i].Split(";")[1];
|
||||
//}
|
||||
//Dictionary<string, List<string>> kundennummerZuWare = new Dictionary<string, List<string>>();
|
||||
//for (int i = 0; i < Schlüssel.Length - 1; i++)
|
||||
//{
|
||||
// string[] einzelneWerte = Werte[i].Split(",");
|
||||
// kundennummerZuWare.Add(Schlüssel[i], einzelneWerte.ToList());
|
||||
//}
|
||||
|
||||
////alle produkte in einer neuen liste sammeln
|
||||
//List<string> produkte = new List<string>();
|
||||
//foreach (var item in kundennummerZuWare)
|
||||
//{
|
||||
// foreach (var item2 in item.Value)
|
||||
// {
|
||||
// produkte.Add(item2);
|
||||
// }
|
||||
//}
|
||||
////doppelte werte entfernen
|
||||
//List<string> eindeutigeProdukte = new List<string>();
|
||||
//foreach (var item in produkte)
|
||||
//{
|
||||
// if (!eindeutigeProdukte.Contains(item))
|
||||
// {
|
||||
// eindeutigeProdukte.Add(item);
|
||||
// }
|
||||
//}
|
||||
////alle keys in einer neuen liste sammeln
|
||||
//List<string> keys = new List<string>();
|
||||
//foreach (var item in kundennummerZuWare)
|
||||
//{
|
||||
// keys.Add(item.Key);
|
||||
//}
|
||||
////doppelte werte etfernen
|
||||
//List<string> eindeutigeKeys = new List<string>();
|
||||
//foreach (var item in keys)
|
||||
//{
|
||||
// if (!eindeutigeKeys.Contains(item))
|
||||
// {
|
||||
// eindeutigeKeys.Add(item);
|
||||
// }
|
||||
//}
|
||||
////ausgabe
|
||||
//Dictionary<string, List<string>> wareZuKundennummer = new Dictionary<string, List<string>>();
|
||||
//foreach (var item in eindeutigeKeys)
|
||||
//{
|
||||
// wareZuKundennummer.Add(item, new List<string>());
|
||||
// foreach (var item2 in kundennummerZuWare)
|
||||
// {
|
||||
// foreach (var item3 in item2.Value)
|
||||
// {
|
||||
// if (wareZuKundennummer.ContainsKey(item3))
|
||||
// {
|
||||
// wareZuKundennummer[item3].Add(item2.Key);
|
||||
|
||||
|
||||
// //wareZuKundennummer.Add(item3, item2.Key);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//Datenbeschaffung = Beispielexemplar einer formatierung Datei
|
||||
string daten = "123; Hammer, Dübel, Nägel\n223; Fischfutter, Sand, Schlauch\n434; Pfanne, Gabel\n001; Apfel, Flasche, Tisch\n727; Laptop, Kabel, Tapete";
|
||||
|
||||
string[] datensätze = daten.Split('\n');
|
||||
|
||||
string[] Schlüssel = new string[datensätze.Length];
|
||||
string[] Werte = new string[datensätze.Length];
|
||||
for (int i = 0; i < datensätze.Length - 1; i++)
|
||||
{
|
||||
Schlüssel[i] = datensätze[i].Split(";")[0];
|
||||
Werte[i] = datensätze[i].Split(";")[1];
|
||||
}
|
||||
|
||||
Console.WriteLine("Dictronary<string ,List<string>> erstellen und füllen");
|
||||
Dictionary<string, List<string>> kundennummerZuWare = new Dictionary<string, List<string>>();
|
||||
for (int i = 0; i < Schlüssel.Length - 1; i++)
|
||||
{
|
||||
string[] einzelneWerte = Werte[i].Split(",");
|
||||
kundennummerZuWare.Add(Schlüssel[i], einzelneWerte.ToList());
|
||||
}
|
||||
foreach (var item in kundennummerZuWare)
|
||||
{
|
||||
Console.WriteLine(item.Key);
|
||||
foreach (var item2 in item.Value)
|
||||
{
|
||||
Console.WriteLine("-" + item2);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("------------------------------------------------------------------------------");
|
||||
List<string> schlüsselliste = new List<string>();
|
||||
foreach (var item in kundennummerZuWare)
|
||||
{
|
||||
foreach (var ware in item.Value)
|
||||
{
|
||||
if (!schlüsselliste.Contains(ware))
|
||||
{
|
||||
schlüsselliste.Add(ware);
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Prüfen ob die Schlüsseliste eindeutig ist");
|
||||
foreach (var item in schlüsselliste)
|
||||
{
|
||||
Console.WriteLine(item);
|
||||
}
|
||||
|
||||
Dictionary<string, List<string>> wareZuKundenNummer = new Dictionary<string, List<string>>();
|
||||
foreach (var item in schlüsselliste)
|
||||
{
|
||||
wareZuKundenNummer.Add(item, new List<string>());
|
||||
}
|
||||
Console.WriteLine("Prüfen ob alle schlüssel gesetzt sind");
|
||||
foreach (var item in wareZuKundenNummer)
|
||||
{
|
||||
Console.WriteLine(item.Key);
|
||||
}
|
||||
|
||||
foreach (var wzkElement in wareZuKundenNummer)
|
||||
{
|
||||
foreach (var kzwElement in kundennummerZuWare)
|
||||
{
|
||||
foreach (var produkt in kzwElement.Value)
|
||||
{
|
||||
if (wzkElement.Key == produkt)
|
||||
{
|
||||
wareZuKundenNummer[produkt].Add(kzwElement.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Prüfung wie das neue Dictionary aussieht: ");
|
||||
|
||||
foreach (var item in wareZuKundenNummer)
|
||||
{
|
||||
Console.WriteLine("Artikel: " + item.Key);
|
||||
foreach (var item2 in item.Value)
|
||||
{
|
||||
Console.WriteLine("-" + item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,31 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielKomposition", "Beis
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielVererbung", "BeispielVererbung\BeispielVererbung.csproj", "{9833AF5B-2E01-41EA-AD1A-49D2159940FD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeispielÜberschreiben", "BeispielÜberschreiben\BeispielÜberschreiben.csproj", "{4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielÜberschreiben", "BeispielÜberschreiben\BeispielÜberschreiben.csproj", "{4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielInterfaces", "BeispielInterfaces\BeispielInterfaces.csproj", "{71D9F5DB-0E81-4586-93E9-E23C2EA5AE37}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielInterface2", "BeispielInterface2\BeispielInterface2.csproj", "{63782CC4-19D6-472E-8FBC-7FB17B9BBC0A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielExceptions", "BeispielExceptions\BeispielExceptions.csproj", "{951D8B4C-C266-45FE-B44E-2AB1A2C2939C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielExceptions2", "BeispielExceptions2\BeispielExceptions2.csproj", "{FF705758-DBDE-4CDB-9CB2-73D10EEC2975}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielRekusion", "BeispielRekusion\BeispielRekusion.csproj", "{2BA6CB32-536E-4287-A655-AC743B5BEC1B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielCesaChiffre", "BeispielCesaChiffre\BeispielCesaChiffre.csproj", "{375B5C7A-E3C7-4693-A4F1-AF664EEF1457}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BesispielDatenTypString", "BesispielDatenTypString\BesispielDatenTypString.csproj", "{738C718E-7941-48B2-96A7-55C60404B083}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeispielGenerischeTypen", "BeispielGenerischeTypen\BeispielGenerischeTypen.csproj", "{474F99BB-3B55-4440-A2AA-4163209FC6C0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerBeispiel", "ContainerBeispiel\ContainerBeispiel.csproj", "{4E49D68A-067F-4889-A91E-57FC3DC623DA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerBeispiel2", "ContainerBeispiel2\ContainerBeispiel2.csproj", "{574CA084-8EA1-4D06-BF13-BE9D617AAEE0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeispielContainer3", "BeispielContainer3\BeispielContainer3.csproj", "{CD88EFFA-EA67-422D-A08F-FBA136B87739}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeispielContainer4", "BeispielContainer4\BeispielContainer4.csproj", "{EE81841D-32CA-4E3B-A228-E2DC9B9B5731}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -123,6 +147,54 @@ Global
|
||||
{4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4C2BC262-68F8-4FC1-A140-E87C2D06E9CB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{71D9F5DB-0E81-4586-93E9-E23C2EA5AE37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71D9F5DB-0E81-4586-93E9-E23C2EA5AE37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71D9F5DB-0E81-4586-93E9-E23C2EA5AE37}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71D9F5DB-0E81-4586-93E9-E23C2EA5AE37}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{63782CC4-19D6-472E-8FBC-7FB17B9BBC0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{63782CC4-19D6-472E-8FBC-7FB17B9BBC0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{63782CC4-19D6-472E-8FBC-7FB17B9BBC0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{63782CC4-19D6-472E-8FBC-7FB17B9BBC0A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{951D8B4C-C266-45FE-B44E-2AB1A2C2939C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{951D8B4C-C266-45FE-B44E-2AB1A2C2939C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{951D8B4C-C266-45FE-B44E-2AB1A2C2939C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{951D8B4C-C266-45FE-B44E-2AB1A2C2939C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FF705758-DBDE-4CDB-9CB2-73D10EEC2975}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FF705758-DBDE-4CDB-9CB2-73D10EEC2975}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FF705758-DBDE-4CDB-9CB2-73D10EEC2975}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FF705758-DBDE-4CDB-9CB2-73D10EEC2975}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2BA6CB32-536E-4287-A655-AC743B5BEC1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2BA6CB32-536E-4287-A655-AC743B5BEC1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2BA6CB32-536E-4287-A655-AC743B5BEC1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2BA6CB32-536E-4287-A655-AC743B5BEC1B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{375B5C7A-E3C7-4693-A4F1-AF664EEF1457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{375B5C7A-E3C7-4693-A4F1-AF664EEF1457}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{375B5C7A-E3C7-4693-A4F1-AF664EEF1457}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{375B5C7A-E3C7-4693-A4F1-AF664EEF1457}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{738C718E-7941-48B2-96A7-55C60404B083}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{738C718E-7941-48B2-96A7-55C60404B083}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{738C718E-7941-48B2-96A7-55C60404B083}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{738C718E-7941-48B2-96A7-55C60404B083}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{474F99BB-3B55-4440-A2AA-4163209FC6C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{474F99BB-3B55-4440-A2AA-4163209FC6C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{474F99BB-3B55-4440-A2AA-4163209FC6C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{474F99BB-3B55-4440-A2AA-4163209FC6C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4E49D68A-067F-4889-A91E-57FC3DC623DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4E49D68A-067F-4889-A91E-57FC3DC623DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4E49D68A-067F-4889-A91E-57FC3DC623DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4E49D68A-067F-4889-A91E-57FC3DC623DA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{574CA084-8EA1-4D06-BF13-BE9D617AAEE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{574CA084-8EA1-4D06-BF13-BE9D617AAEE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{574CA084-8EA1-4D06-BF13-BE9D617AAEE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{574CA084-8EA1-4D06-BF13-BE9D617AAEE0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CD88EFFA-EA67-422D-A08F-FBA136B87739}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CD88EFFA-EA67-422D-A08F-FBA136B87739}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CD88EFFA-EA67-422D-A08F-FBA136B87739}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CD88EFFA-EA67-422D-A08F-FBA136B87739}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EE81841D-32CA-4E3B-A228-E2DC9B9B5731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EE81841D-32CA-4E3B-A228-E2DC9B9B5731}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE81841D-32CA-4E3B-A228-E2DC9B9B5731}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE81841D-32CA-4E3B-A228-E2DC9B9B5731}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user