Below is a sample soucrecode demonstrating how to get remainder in c# using Modulus or Remainder operator (%).

# Using Modulus or % to get the Remainder in C#

using System; namespace AbundantCode { internal class Program { //Using Modulus or % to get the Remainder in C# private static void Main(string[] args) { int result; double Input; var output = 10 % 3; Console.WriteLine("Remainder = " + output.ToString()); Console.ReadLine(); } } }

Nice, easy, simple tutorial with even simpler code to understand. Thank you.

For those who are more curious, this article examines the fastest way to get the remainder between using modulus or an alternative with addition:

http://blogs.davelozinski.com/curiousconsultant/csharp-net-use-the-modulus-operator-or-alternative

It’s obviously more for speed and micro-optimization junkies.

🙂

_