Zum Hauptinhalt springen
ProdukteDesktop-WerkzeugeTASTECADZeichnungsprüfungTASTEFILESDateiverwaltungTASTEFTPDateiübertragungTASTESSHRemote-ArbeitsbereichTASTEZIPKomprimieren und EntpackenTASTEWINMDateiverwaltungEntwicklerwerkzeugeTASTECODEIntegrierte Entwicklungsumgebung für RustTASTESTUDIOIntegrierte Entwicklungs- und TestumgebungTASTEETLDatenintegration (ETL)ServerTASTEREMOTERemote-Desktop-ServerTASTEGEOGeodatenserverTASTEMAILE-Mail-ArbeitsbereichInvestierenTASTESTOCKDesktop-App für automatischen AktienhandelErste SchritteDownloadsDokumentationKaufenAlle Produkte
Marktplatz
Neuigkeiten
TechnikNeuigkeitenEntwickler-News von heuteEntwicklerdokuProgrammiersprachenRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp- & Desktop-FrameworksTauriFlutterReact NativeElectronAlgorithmenAlgorithmus-GrundlagenKernalgorithmenFortgeschrittene AlgorithmenAlgorithmen für die Praxis
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcaseCommunity-Leitfaden
ZusammenarbeitWissenstransferWebsite-AufbauDesktop-App-AufbauRelease- und ZahlungspipelineVertriebspartnerKontakt
DiensteRemote-DesktopIndividuelle Installationspakete
TASTEDEV
Produkte

Desktop-Werkzeuge

TASTECADKomplexe Zeichnungen, mühelos geöffnetTASTEFILESNur die Dateien, die zählen – in BestzeitTASTEFTPDer aufgeräumteste Weg für Ihre DateienTASTESSHDie stärkere Verbindung zu Ihren ServernTASTEZIPSchneller packen, sicherer entpackenTASTEWINMEin tastaturorientierter Dateimanager mit zwei Fenstern

Entwicklerwerkzeuge

TASTECODERust-Apps bearbeiten, bauen, debuggen und testen – alles in einem FensterTASTESTUDIOVom Bearbeiten bis zu Remote-Tests und freigegebenen KI-KorrekturenTASTEETLDaten bewegen, die Werte im Blick

Server

TASTEREMOTEEin Remote-Desktop auf Ihrem eigenen ServerTASTEGEOEin GeoServer-kompatibler Geodatenserver, neu aufgebaut in RustTASTEMAILIhre E-Mail wieder in Ihrer Hand

Investieren

TASTESTOCKAutomatischer Aktienhandel nach Ihren Regeln: wann und was

Erste Schritte

DownloadsNeueste Versionen aller ProdukteDokuSo nutzen Sie jedes ProduktKaufenAbos und DauerlizenzenAlle ProdukteAlle Produkte im Überblick
Alle Produkte
MarktplatzNeuigkeiten
Technik

Neuigkeiten

Entwickler-News von heuteOffizielle Meldungen zu Sprachen, Frameworks, GitHub und KIEntwicklerdokuAnleitungen zu Sprachen, Frameworks und Algorithmen

Programmiersprachen

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App- & Desktop-FrameworksTauriFlutterReact NativeElectron

Algorithmen

Algorithmus-GrundlagenKomplexitätsanalyse · Sortieren · Suchen · Grundlegende Datenstrukturen · Bäume und HeapsKernalgorithmenGraphtraversierung · Kürzeste Wege und minimale Spannbäume · Dynamische Programmierung · Greedy-Algorithmen · Teile und herrsche · BacktrackingFortgeschrittene AlgorithmenZeichenkettenalgorithmen · Mathematik und Zahlentheorie · Bitmanipulation · Segmentbäume · Union-FindAlgorithmen für die PraxisStrategie für Coding-Interviews · LRU-Cache · Rate Limiting · Konsistentes Hashing
Alle Entwicklungsdokumente
Community
ProjekteEntwickler und Projekte entdeckenEntwicklungslogsEntscheidungen und ErkenntnissePromptsWiederverwendbare AnweisungenProbleme mit KI-ToolsProbleme und Workarounds für Claude, Codex, GeminiShowcaseFertige ErgebnisseCommunity-LeitfadenWie wir offen entwickeln
Zusammenarbeit
WissenstransferNative Apps mit Rust und eguiWebsite-Aufbau10 Sprachen, Konten, Dokumentation und DownloadsDesktop-App-AufbauRust und egui, ohne WebViewRelease- und ZahlungspipelineSignatur, MSI, deb, rpm, AppImage, PrüfsummenVertriebspartnerEmpfehlen und 30 % erhaltenKontaktEntwicklung, Partnerschaft, Investition
Dienste
Remote-DesktopIhren Computer im Browser erreichenIndividuelle InstallationspaketeNur nötige Funktionen, Einstellungen vorab
Kaufen
DE
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Anmelden
Anmelden
TASTEDEV

Von kleinen Werkzeugen zu besserer Entwicklung.

support@tastedev.netTASTEDEV unterstützen
ProdukteProduktübersichtKaufenDokuDownloadsMarktplatzSupport
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcase
RichtlinienÜber unsDatenschutzerklärungNutzungsbedingungenAbo-BedingungenRückerstattungCommunity-Richtlinien
KontoAnmeldenRegistrieren
Besucher
Heute
Gestern
Aufrufe gesamt
Firma
GXSOFT
Vertretungsberechtigt
CHOI YOUNG GU
Handelsregisternummer
853-44-00368
Anschrift
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefon
+82-10-4404-1523
E-Mail
whitecalvin@tastedev.net
Datenschutzbeauftragter
CHOI YOUNG GU

© 2026 TASTEDEVProduktinformationen basieren auf verifizierten Entwicklungsquellen.Veröffentlicht · wird verbessert

C#-Dokumentation
C#
Getting Started with CSyntax BasicsTypes and DataProjects and PackagesErrors and TestingKey Concepts: LINQ, Delegates, and Async
Diskussionen

C#-Anleitung · 6/6

Key Concepts: LINQ, Delegates, and Async

Dieses Kapitel ist vorerst nur auf Englisch verfügbar.

Three features give C# much of its character: delegates and lambdas for passing functions as values, LINQ for declarative queries, and async/await for waiting on I/O without tying up a thread. Each builds on the one before it.

Delegates and Lambdas

A delegate is a type-safe reference to a method. You can declare your own delegate types, but most code uses the built-in Func<...> (returns a value) and Action<...> (returns nothing). A lambda expression, (parameters) => expression, creates an anonymous method on the spot.

Func<int, int, int> add = (a, b) => a + b;
Func<string, bool> isLong = s => s.Length > 5;
Action<string> log = message => Console.WriteLine($"[log] {message}");

Console.WriteLine(add(2, 3));          // 5
Console.WriteLine(isLong("TASTEDEV")); // True
log("starting up");

// a method that takes another function as an argument
static List<int> Apply(List<int> items, Func<int, int> transform)
{
    var result = new List<int>();
    foreach (var item in items)
        result.Add(transform(item));
    return result;
}

var doubled = Apply([1, 2, 3], x => x * 2); // [2, 4, 6]

// lambdas can capture variables from the surrounding scope
int threshold = 10;
Func<int, bool> overThreshold = x => x > threshold;

Events build on delegates too: button.Click += (sender, e) => ... attaches a lambda to an event.

LINQ

LINQ (Language Integrated Query) gives you one consistent way to query arrays, lists, databases, and other data sources. The most common style is method syntax: chaining extension methods from System.Linq and passing lambdas to them.

List<Order> orders =
[
    new("Ana", "Books", 18.00m),
    new("Ben", "Electronics", 320.00m),
    new("Ana", "Electronics", 45.00m),
    new("Cai", "Books", 22.00m),
];

var bigOrders = orders
    .Where(o => o.Amount >= 20m)
    .OrderByDescending(o => o.Amount)
    .Select(o => $"{o.Customer}: {o.Amount:F2}")
    .ToList();

var byCategory = orders
    .GroupBy(o => o.Category)
    .Select(g => new { Category = g.Key, Total = g.Sum(o => o.Amount), Count = g.Count() });

foreach (var row in byCategory)
    Console.WriteLine($"{row.Category}: {row.Count} orders, {row.Total:F2} total");

bool anyExpensive = orders.Any(o => o.Amount > 100m);
var first = orders.FirstOrDefault(o => o.Customer == "Cai");

record Order(string Customer, string Category, decimal Amount);

(With top-level statements, type declarations go last.) Query syntax reads more like SQL and compiles to the same method calls:

var query =
    from o in orders
    where o.Category == "Books"
    orderby o.Amount
    select o.Customer;

LINQ uses deferred execution: Where and Select only describe a query, which runs when you enumerate it or call , , or . Enumerating twice runs it twice, so call once if you will reuse the results.

Fragen zu diesem Kapitel?
Vorheriges KapitelErrors and Testing
ToList
Count
First
ToList()

async/await and Task

File, network, and database operations spend most of their time waiting. An async method hands its thread back at each await while the operation is in flight, then resumes on the next line once it completes. Async methods return Task when they produce no value and Task<T> when they do.

using var http = new HttpClient();

static async Task<int> GetLengthAsync(HttpClient client, string url, CancellationToken token)
{
    string body = await client.GetStringAsync(url, token);
    return body.Length;
}

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));

try
{
    // await one operation at a time
    int length = await GetLengthAsync(http, "https://learn.microsoft.com", cts.Token);
    Console.WriteLine($"Length: {length}");

    // start several operations at once and wait for all of them
    string[] urls = ["https://dotnet.microsoft.com", "https://www.nuget.org"];
    int[] lengths = await Task.WhenAll(urls.Select(u => GetLengthAsync(http, u, cts.Token)));
    Console.WriteLine(string.Join(", ", lengths));
}
catch (OperationCanceledException)
{
    Console.WriteLine("Timed out, so the requests were cancelled.");
}

Top-level statements can use await directly. A handful of rules will keep you out of most async trouble:

  • Give async methods an Async suffix and have them return Task or Task<T>.
  • Reserve async void for event handlers, because callers cannot catch its exceptions.
  • Don't block on async work with .Result or .Wait(); await all the way up. Blocking is a classic cause of deadlocks.
  • Accept a CancellationToken in long-running operations so they can be stopped.
  • Run independent operations concurrently with Task.WhenAll.

Reuse HttpClient instead of creating one per request; web apps usually get clients from IHttpClientFactory.

Summary

  • Func and Action delegates hold lambdas, letting you pass behavior as a value; lambdas can capture surrounding variables.
  • LINQ chains operators like Where, Select, GroupBy, and OrderBy to work with data declaratively, and it runs only when results are needed.
  • async/await with Task keeps threads free while waiting, and CancellationToken makes long operations cancellable.

Further Reading

  • C# documentation: the official language tour, tutorials, and language reference.
  • .NET documentation: guides to the runtime, libraries, and the dotnet CLI.
  • LINQ overview: query syntax and the standard query operators in depth.
  • Asynchronous programming: the async/await model and task-based patterns.
  • .NET API browser: look up any type or member in the base class libraries.
  • NuGet Gallery: search public packages and review their details.

0 Kommentare

Top-KommentareNeueste zuerst

Anmelden · Melde dich an, um einen Kommentar zu schreiben.