Facebook Page Twitter Page LinkedIn Page
× C# Tutorial C# Advanced C# Resources


The C# Math Cos() method is used to return trigonometric cosine of an angle (angle should be in radians). In special cases it returns the following:

  • If the argument is NaN, NegativeInfinity or PositiveInfinity, the method returns NaN.

Syntax

public static double Cos (double arg);

Parameters

arg Specify the angle in radian.

Return Value

Returns the trigonometric cosine of an angle.

Example:

In the below example, Cos() method is used to find out the trigonometric cosine of an angle.

using System;

class MyProgram {
  static void Main(string[] args) {
   double pi = Math.PI;
   Console.WriteLine(Math.Cos(pi/6));
   Console.WriteLine(Math.Cos(pi/4));
   Console.WriteLine(Math.Cos(pi/3));
  }
}

The output of the above code will be:

0.866025403784439
0.707106781186548
0.5

❮ C# Math Methods