December 2026
Every post published in December 2026, newest first. Pick a day to jump straight to it.
- Posts
- 97
- Topics
- 38
- Reading time
- 10 h
- Active days
- 1
Posts 91–97 of 97 · December 1, 2026
Page 4 of 4
Tuesday, December 1, 2026
7 of 97 posts
How to Add, Subtract, Multiply and Divide Numbers in C#
Add, subtract, multiply and divide numbers in C# with +, -, * and /. A small example works with 17 and 5, where 17 / 5 gave 3 as whole numbers and 3.4 as doubles, and 2 + 3 * 4 gave 14, with real output, the DivideByZeroException and what happens past int.MaxValue.
7 min readHow to Switch on Two Values at Once with a Tuple Pattern in C#
A tuple pattern lets a C# switch expression match two values at once: put them in parentheses, such as (isCold, isRaining), and write one arm per combination. A small example picks clothes for all four weather combinations and builds with 0 warnings, with the CS8509 warning, the CS8502 and CS8510 errors and a swapped-order bug you can hit on the way.
6 min readHow to Find the Position of an Item in a List with FindIndex in C#
List<T>.FindIndex in C# returns the position of the first item that passes a test, or -1 when none does. A small example finds milk at index 1 in a shopping list, replaces it through that index, finds melon at index 3 with a start position, and gets -1 for z, with real output and the mistakes to avoid.
7 min readHow to Put an Attribute on a Lambda Parameter in C#
In C#, an attribute can go on a lambda's parameter, written inside the parentheses in front of it. A small example puts Description on the celsius parameter of a Celsius-to-Fahrenheit lambda, prints 100 C is 212 F, reads the description back with reflection, and shows the errors for missing parentheses and a wrong attribute.
6 min readHow to Convert a String to a double with double.Parse in C#
Convert a string to a double in C# with double.Parse and a culture. A small example reads "3.5" and "1.25" with the invariant culture and adds them up to 4.75, then shows why "3.5" read as German became 35, with real output, the FormatException for "$4.99" and Infinity for 1e400.
6 min readHow to Match Several Patterns with or in C#
The or pattern in C# matches a value against several patterns at once, so one switch arm or one is check covers them all. A small example sorts a, b, e and x into vowels and consonants with one arm for all five vowels and checks a grade with is 'A' or 'B', with the errors you get from ||, a variable inside or, and not without parentheses.
6 min readHow to Run Several Tasks at Once and Wait for All of Them with Task.WhenAll in C#
Task.WhenAll in C# waits for several tasks that run at the same time and gives back all their results in the order you passed them in. A small example makes tea, toast and an egg that take 3, 2 and 1 seconds, all done after 3.0 seconds instead of 6, with real output and what happens when two of the tasks throw.
8 min read