Commit dc78d7fc authored by Uwe Wienkop's avatar Uwe Wienkop

2020-06-10 Mi

parent d79c6e4d
......@@ -115,16 +115,15 @@ namespace _06GenericList
// an der gespeicherten Pos. weitergemacht.
}
}
public delegate bool MyFilter<V>(V daten);
public IEnumerable<T> Filter(MyFilter<T> myTest) // string => bool, x => x.Contains("er")
public delegate bool MyFilter1(T daten); // Typpar. T wird vom äußeren Class<T> genommen
public delegate bool MyFilter2<V>(V daten); // Typpar. V zunächst noch offen und wird dann
// bei der Verwendung in Filter auf MyFilter2<T> gesetzt ~ Predicate<T>
public IEnumerable<T> Filter(Predicate<T> myTest) // string => bool, x => x.Contains("er")
{
for (Element item = anf; item != null; item = item.next)
{
if (myTest(item.daten))
yield return item.daten; // Merken dieser Ausführungsposition
// UND Zurückliefern von item.name
// Beim nächsten Aufruf von GetEnumerator() wird
// an der gespeicherten Pos. weitergemacht.
if (myTest(item.daten)) // if (item.daten.Contains(pattern))
yield return item.daten;
}
}
......
......@@ -4,7 +4,7 @@ namespace _06GenericList
{
class Person : IComparable<Person>
{
string name, vorname;
public string name, vorname;
public Person(string name, string vorname)
{
this.name = name;
......@@ -19,16 +19,28 @@ namespace _06GenericList
}
class Program
{
static bool IstGerade(uint z)
{
return z % 2 == 0;
}
private static string pattern;
static bool Namenstest(Person x)
{
return x.name.Contains(pattern) &&
(x.vorname.Contains("e") || x.vorname.Contains("E"));
}
static void Main(string[] args)
{
Liste<int> il = new Liste<int>();
Liste<uint> il = new Liste<uint>();
il.AddEnd(10);
il.AddEnd(20);
il.AddEnd(23);
il.AddEnd(21);
il.AddEnd(35);
il.AddEnd(40);
foreach (var item in il.Filter(x => x%2==0))
//foreach (var item in il.Filter(x => x % 2 == 0))
foreach (var item in il.Filter(IstGerade)) // T => bool
{
Console.WriteLine(item);
}
......@@ -45,15 +57,25 @@ namespace _06GenericList
Console.WriteLine(item);
}
Console.WriteLine("*****************");
sl.Print();
//sl.Print();
Liste<Person> pl = new Liste<Person>();
pl.AddSorted(new Person("Meier", "Emil"));
pl.AddSorted(new Person("Schmitt", "Anton"));
pl.Print();
pl.AddSorted(new Person("Huber", "Dieter"));
pl.AddSorted(new Person("Müller", "Berta"));
//foreach (var item in pl.Filter(x => x.name.Contains("er")&&(x.vorname.Contains("e")||x.vorname.Contains("E"))))
//foreach (var item in pl.Filter(x => x.name.Length<6 && x.vorname.Contains("er")))
pattern = "er";
foreach (var item in pl.Filter(Namenstest))
{
Console.WriteLine(item);
}
//pl.Print();
Liste<Liste<Person>> pll = new Liste<Liste<Person>>();
pll.AddSorted(pl);
//Liste<Liste<Person>> pll = new Liste<Liste<Person>>();
//pll.AddSorted(pl);
}
}
......
......@@ -10,3 +10,4 @@ C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06GenericList\obj\Debug\netco
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06GenericList\obj\Debug\netcoreapp3.1\06GenericList.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06GenericList\obj\Debug\netcoreapp3.1\06GenericList.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06GenericList\obj\Debug\netcoreapp3.1\06GenericList.genruntimeconfig.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06GenericList\obj\Debug\netcoreapp3.1\06GenericList.csprojAssemblyReference.cache
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_08_DelegateAnwendungen</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _08_DelegateAnwendungen
{
class Program
{
delegate T MeineFkt<T>(T x);
//delegate bool MeinTest<T>(T x);
static T[] ApplyAll<T>(MeineFkt<T> fkt, params T[] werte)
{
T[] erg = new T[werte.Length];
for (int i = 0; i < werte.Length; i++)
{
erg[i] = fkt(werte[i]);
Console.Write (erg[i]); Console.Write(" ");
}
Console.WriteLine();
return erg;
}
static int Quadrieren(int x) => x * x;
static void Main(string[] args)
{
ApplyAll(x => (int) (x * 1.02), 10, 30, 40, 50, 60, 70, 80, 100);
ApplyAll(x => x + 1, 10, 30, 40, 50, 60, 70, 80, 100);
ApplyAll(x => x * 2, 10, 30, 40, 50, 60, 70, 80, 100);
ApplyAll(Quadrieren, 10, 30, 40, 50, 60, 70, 80, 100);
Console.WriteLine("----------");
string[] namen = { "Anton", "Berta", "Claudia", "Emil", "Dieter" };
ApplyAll(x => x.ToUpper(), namen);
}
}
}
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"08 DelegateAnwendungen/1.0.0": {
"runtime": {
"08 DelegateAnwendungen.dll": {}
}
}
}
},
"libraries": {
"08 DelegateAnwendungen/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\wienkop\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\wienkop\\.nuget\\packages"
]
}
}
\ No newline at end of file
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}
\ No newline at end of file
{
"format": 1,
"restore": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\08 DelegateAnwendungen.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\08 DelegateAnwendungen.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\08 DelegateAnwendungen.csproj",
"projectName": "08 DelegateAnwendungen",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\08 DelegateAnwendungen.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[3.1.2, 3.1.2]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.300\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\wienkop\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("08 DelegateAnwendungen")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("08 DelegateAnwendungen")]
[assembly: System.Reflection.AssemblyTitleAttribute("08 DelegateAnwendungen")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\bin\Debug\netcoreapp3.1\08 DelegateAnwendungen.exe
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\bin\Debug\netcoreapp3.1\08 DelegateAnwendungen.deps.json
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\bin\Debug\netcoreapp3.1\08 DelegateAnwendungen.runtimeconfig.json
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\bin\Debug\netcoreapp3.1\08 DelegateAnwendungen.runtimeconfig.dev.json
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\bin\Debug\netcoreapp3.1\08 DelegateAnwendungen.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\bin\Debug\netcoreapp3.1\08 DelegateAnwendungen.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.AssemblyInfoInputs.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.AssemblyInfo.cs
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.csproj.CoreCompileInputs.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.genruntimeconfig.cache
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.1": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.1": []
},
"packageFolders": {
"C:\\Users\\wienkop\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\08 DelegateAnwendungen.csproj",
"projectName": "08 DelegateAnwendungen",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\08 DelegateAnwendungen.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[3.1.2, 3.1.2]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.300\\RuntimeIdentifierGraph.json"
}
}
}
}
\ No newline at end of file
{
"version": 2,
"dgSpecHash": "OVSCFwchQklO0pDasjI/NgjUxPFohB4mbvQIh2TyVZ3DCNl1CD5VttCC6m5b7UXAcLHdzwOpNE4zZJ/V2jGg0w==",
"success": true,
"projectFilePath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\08 DelegateAnwendungen\\08 DelegateAnwendungen.csproj",
"expectedPackageFiles": [
"C:\\Users\\wienkop\\.nuget\\packages\\microsoft.aspnetcore.app.ref\\3.1.2\\microsoft.aspnetcore.app.ref.3.1.2.nupkg.sha512"
],
"logs": []
}
\ No newline at end of file
......@@ -96,6 +96,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "08DelegateIntro", "08Delega
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "08 UebgDiDatentypSet", "08 UebgDiDatentypSet\08 UebgDiDatentypSet.csproj", "{42061739-142A-4941-81EB-7217DD563CC6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "08 DelegateAnwendungen", "08 DelegateAnwendungen\08 DelegateAnwendungen.csproj", "{934A5FBA-46BF-4399-A48D-210D22F070FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -278,6 +280,10 @@ Global
{42061739-142A-4941-81EB-7217DD563CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42061739-142A-4941-81EB-7217DD563CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42061739-142A-4941-81EB-7217DD563CC6}.Release|Any CPU.Build.0 = Release|Any CPU
{934A5FBA-46BF-4399-A48D-210D22F070FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{934A5FBA-46BF-4399-A48D-210D22F070FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{934A5FBA-46BF-4399-A48D-210D22F070FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{934A5FBA-46BF-4399-A48D-210D22F070FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment