Converts a radians angle into a degrees angle.

   
 

    public static class MathUtility
    {
        //-------------------------------------------------------------------------------------
        /// <summary>
        /// Converts a radians angle into a degrees angle.
        /// </summary>
        /// <param name="angle">Angle to convert.</param>
        /// <returns>Angle in degrees.</returns>
        //-------------------------------------------------------------------------------------

        public static float RadiansToDegrees(float angle)
        {
            return angle * (180.0f / (float) System.Math.PI);
        }
    }

   
     


Converts a degrees angle into a radians angle.

   
 

    public static class MathUtility
    {

        //-------------------------------------------------------------------------------------
        /// <summary>
        /// Converts a degrees angle into a radians angle.
        /// </summary>
        /// <param name="angle">Angle to convert.</param>
        /// <returns>Angle in radians.</returns>
        //-------------------------------------------------------------------------------------

        public static float DegreesToRadians(float angle)
        {
            return angle * ((float) System.Math.PI / 180.0f);
        }

     }

   
     


Math.Abs

   
  
using System;

public class MainClass {
    public static void Main() {

        Console.WriteLine("Math.Abs(5) = {0}", Math.Abs(5));
        Console.WriteLine("Math.Abs(-5) = {0}", Math.Abs(-5));
        Console.WriteLine("Math.Abs(0) = {0}", Math.Abs(0));
    }
}

   
     


Math.Sign

   
  
using System;

public class MainClass {
    public static void Main() {
        Console.WriteLine("Math.Sign(1) = {0}", Math.Sign(1));
        Console.WriteLine("Math.Sign(-1) = {0}", Math.Sign(-1));
        Console.WriteLine("Math.Sign(0) = {0}", Math.Sign(0));
    }
}

   
     


Use Math.Round

   
  

using System;

public class MainClass {
    public static void Main() {

        Console.WriteLine(Math.Round(4.4));
        Console.WriteLine(Math.Round(4.5));
        Console.WriteLine(Math.Round(4.6));
        Console.WriteLine(Math.Round(5.5));
        Console.WriteLine(Math.Round(4.54, 1));
        Console.WriteLine(Math.Round(4.55, 1));
        Console.WriteLine(Math.Round(4.65, 1));
        Console.WriteLine(Math.Round(4.56, 1));
    }
}

   
     


Math operators

   
  

using System;
class MathOpsApp
{
    static void Main(string[] args)
    {
        Random rand = new Random();
        int a, b, c;
   
        a = rand.Next() % 100; // Limit max to 99.
        b = rand.Next() % 100; // Limit max to 99.
   
        Console.WriteLine("a={0} b={1}", a, b);
   
        c = a * b;
        Console.WriteLine("a * b = {0}", c);
   
        c = a / b;
        Console.WriteLine("a / b = {0}", c);
   
        c = a + b;
        Console.WriteLine("a + b = {0}", c);
   
        c = a - b;
        Console.WriteLine("a - b = {0}", c);
   
        c = a % b;
        Console.WriteLine("a % b = {0}", c);
    }
}