How to Reverse an Array in C# (8 Methods with Examples)

Reverse an array in C#: TX, CA, NY, FL becomes FL, NY, CA, TX with Array.Reverse(states)

Your sales report lists January first, but the dashboard wants the newest month on top. To reverse an array in C#, call Array.Reverse(arr). It flips the array in place in one line. In this tutorial, I’ll walk through eight ways to reverse an array in C#, from the built-in method to loops that skip Reverse() … Read more >>

Inheritance in C#: A Field Guide with Real Examples (.NET 10)

Inheritance in C#: override runs Manager.Describe through an Employee reference while new hides Label and runs the Employee version

Payroll code is where I see inheritance used well and abused most. Inheritance in C# lets a derived class reuse and extend a base class: write class Employee : Person, and every Employee gets the members of Person plus its own. In this tutorial, I’ll map out how inheritance in C# really behaves on .NET … Read more >>

Prime Number Program in C#: Check, List and Sieve Primes

Prime number program in C#: boxes 2 to 13 with the primes 2, 3, 5, 7, 11 and 13 highlighted, and the count of 25 primes from 1 to 100

Is 97 prime? A prime number program in C# answers that by trying divisors: return false below 2, return n == 2 for even numbers, then test odd divisors while i <= n / i. If none divides evenly, it’s prime. In this tutorial, I’ll grow one small PrimeTools class step by step, the way … Read more >>