contentintech
Languages

C#

Collections, LINQ and asynchronous code in modern C#.

Tooling

dotnet new console -n DemoCreate a console project
dotnet buildBuild the project
dotnet runRun the project
dotnet testRun tests in a test project or solution

Collections and LINQ

var names = new List<string> { "Ada", "Lin" };Create a mutable list
names.Add("Sam");Append an element
names.Where(n => n.StartsWith("A")).ToList();Materialize a filtered sequence
names.Select(n => n.ToUpperInvariant());Produce a lazy projection

Nulls and async

string? nickname = null;Permit null with nullable reference types enabled
var length = nickname?.Length ?? 0;Safely access a nullable string
var text = await File.ReadAllTextAsync(path);Read without blocking the calling thread
using var stream = File.OpenRead(path);Dispose a resource at the end of its scope

Section navigation