Results for “dot”
Small, practical examples. Search by task or narrow things down below.
Find values missing from another collection
C#: Except removes duplicates as it calculates the set difference.
C#✓ Tested
Find what remains after division
C#: Use the remainder operator to count items left after forming complete groups.
C#✓ Tested
Flatten nested collections with SelectMany
C#: Concatenate the items from several sequences into one sequence.
C#✓ Tested
Format a decimal amount
Use invariant culture to print a C# decimal with two places.
C#✓ Tested
Handle malformed JSON
C#: Catch JsonException for malformed JSON without swallowing unrelated failures.
C#✓ Tested
Handle three possible outcomes
C#: Check high, normal and low values with an ordered conditional chain.
C#✓ Tested
Hash a UTF-8 value with SHA-256
C#: Use SHA256.HashData for a one-shot content digest.
C#✓ Tested
Increment a shared counter atomically
C#: Interlocked performs an indivisible update without a separate lock for this operation.
C#✓ Tested
Inspect a file length without reading it
C#: Use FileInfo.Length to retrieve a logical size in bytes.
C#✓ Tested
Inspect a parsed URI
C#: Use Uri properties instead of splitting URL strings manually.
C#✓ Tested
Limit concurrent access with SemaphoreSlim
C#: Release the semaphore in finally so exceptions cannot leave it permanently acquired.
C#✓ Tested
List matching files
Enumerate immediate text files and sort their names in C#.
C#✓ Tested