Math.Sin() Method in C#


The Math.Sin() method in C# is used to return the sine of a specified angle.

Syntax

Following is the syntax −

public static double Sin (double val);

Above, the argument value is an angle.

Example

Let us now see an example to implement Math.Sin() method −

using System;
public class Demo {
   public static void Main(){
      double val1 = 30.0;
      Console.WriteLine(Math.Sin( (val1 * (Math.PI)) / 180 ));
   }
}

Output

This will produce the following output −

0.5

Example

Let us see another example to implement Math.Sin() method −

using System;
public class Demo {
   public static void Main(){
      double val1 = 45.0;
      double val2 = Double.PositiveInfinity;
      double val3 = Double.NaN;
      Console.WriteLine(Math.Sin( (val1 * (Math.PI)) / 180 ));
      Console.WriteLine(Math.Sin(val2));
      Console.WriteLine(Math.Sin(val3));
   }
}

Output

This will produce the following output −

0.707106781186547
NaN
NaN

Updated on: 08-Nov-2019

599 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements