Results for “dot”
Small, practical examples. Search by task or narrow things down below.
Count the items in a collection
C#: Read the collection’s length instead of hard-coding the loop limit.
C#✓ Tested
Count words with GroupBy
Group repeated C# words and print ordered counts.
C#✓ Tested
Create a file only when it does not exist
C#: FileMode.CreateNew prevents accidental replacement of existing content.
C#✓ Tested
Create a modified copy of an immutable record
C#: A with expression creates a shallow copy with selected changed properties.
C#✓ Tested
Create a reusable one-to-many lookup
C#: ToLookup groups values by key and returns an empty sequence for an unknown key.
C#✓ Tested
Create nested directories
Create a directory tree using the .NET Directory API.
C#✓ Tested
Decode hexadecimal bytes
C#: FromHexString and ToHexString handle binary data without manually parsing pairs of characters.
C#✓ Tested
Delete a known scratch file
C#: File.Delete ignores a missing file but still throws for other I/O failures.
C#✓ Tested
Deserialize a JSON object into a dictionary
C#: Specify the value type expected from a known JSON shape.
C#✓ Tested
Detect integer overflow with checked
C#: A checked arithmetic block throws instead of silently wrapping an integer result.
C#✓ Tested
Divide using a fractional number
C#: Use a floating-point operand to preserve the fractional part of a division.
C#✓ Tested
Enumerate matching files recursively
C#: Sort relative filenames when reproducible traversal output is required.
C#✓ Tested