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

Anonyme Typen, Personalverwaltung

parent a137403f
Branches
No related tags found
No related merge requests found
Showing
with 139 additions and 4 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -36,10 +36,10 @@ namespace _02_OpUeberladenBrueche
public static bool operator !=(Bruch b1, Bruch b2)
=> !(b1 == b2);
public static implicit operator Bruch(int k) => new Bruch(k);
public static implicit operator Bruch(int k) => new Bruch(k); // 2 -> 2/1
// Konvertierung int --> Bruch
public static explicit operator int(Bruch b) => b.z/b.n;
public static implicit operator Bruch(string s)
public static explicit operator int(Bruch b) => b.z/b.n; // z.B. 2/3 --> 0
public static implicit operator Bruch(string s) // z.B. "1/3" -> 1/3
{
string[] d = s.Split('/');
int z = Convert.ToInt32(d[0]);
......@@ -72,7 +72,7 @@ namespace _02_OpUeberladenBrueche
Console.WriteLine(Bruch.Mult3(b1,b2));
// b1*b2 --> Bruch.ToString() --> Ausgabe
int d = (int) (3.14 + 3);
int d = (int) 3.14;
g(2, 3.14);
g(2, 3); // Implizite Konvertierung 3 --> 3.0
......
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -37,6 +37,7 @@ namespace _22_Informationsverteiler
mb.callback += p1.MyPrint;
mb.callback += p2.MyPrint;
// mb.callback("Hallo"); -- ist nicht erlaubt. Nur Methoden in der Klasse MessageBox dürfen callback aufrufen
mb.Send("Hallo");
Console.WriteLine("------------------");
......
File added
No preview for this file type
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_24_DelegateVerkettung</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _24_DelegateVerkettung
{
public delegate double MyFunction(double x);
class MyClass
{
public static double MalEins(double x) { Console.WriteLine($"MalEins({x}): "); return x * 1; }
public static double MalZwei(double x) { Console.WriteLine($"MalZwei({x}): "); return x * 2; }
public static double MalDrei(double x) { Console.WriteLine($"MalDrei({x}): "); return x * 3; }
}
class Program
{
static void Main(string[] args)
{
MyClass m = new MyClass();
MyFunction f = new MyFunction(MyClass.MalEins);
f += MyClass.MalZwei;
f += MyClass.MalDrei;
Console.WriteLine(f(3));
}
}
}
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"24 DelegateVerkettung/1.0.0": {
"runtime": {
"24 DelegateVerkettung.dll": {}
}
}
}
},
"libraries": {
"24 DelegateVerkettung/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
File added
File added
File added
{
"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\\oop-ss2023-wienkop\\OOP2023\\24 DelegateVerkettung\\24 DelegateVerkettung.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\24 DelegateVerkettung\\24 DelegateVerkettung.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\24 DelegateVerkettung\\24 DelegateVerkettung.csproj",
"projectName": "24 DelegateVerkettung",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\24 DelegateVerkettung\\24 DelegateVerkettung.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\24 DelegateVerkettung\\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": {
"targetAlias": "netcoreapp3.1",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"targetAlias": "netcoreapp3.1",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.416\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment