C# Math.Sin() – Examples

In this tutorial, we will learn about the C# Math.Sin() method, and learn how to use this method to find the sine of given angle, with the help of examples.

Sin(Double)

Math.Sin(a) returns the sine of the specified angle a. Sin() function considers the specified angle in radians.

Syntax

The syntax of Sin() method is

Math.Sin(Double a)

where

ParameterDescription
aThe angle in radians.

Return Value

The method returns double value.

Example 1 – Sin(45 degrees)

In this example, we will compute sine for 45 degrees. We know that sin(45 degrees) is inverse of square root 2.

C# Program

using System;

class Example {
    static void Main(string[] args) {
        Double angle = Math.PI/4; //45 degrees

        Double value = Math.Sin(angle);
        Console.WriteLine($"Sine ({(180 / Math.PI) * angle} degrees) = {value}");
    }
}

Output

Sine (45 degrees) = 0.707106781186548

Example 2 – Sin(90 degrees)

In this example, we will compute sine for 90 degrees. We know that sin(90 degrees) is 1.

C# Program

using System;

class Example {
    static void Main(string[] args) {
        Double angle = Math.PI/2; //90 degrees

        Double value = Math.Sin(angle);
        Console.WriteLine($"Sine ({(180 / Math.PI) * angle} degrees) = {value}");
    }
}

Output

Sine (90 degrees) = 1

Example 3 – Sin(-60 degrees)

In this example, we will compute sine for -60 degrees. We know that sin(-60 degrees) is -0.5

C# Program

using System;

class Example {
    static void Main(string[] args) {
        Double angle = -Math.PI/6; //-60 degrees

        Double value = Math.Sin(angle);
        Console.WriteLine($"Sine ({(180 / Math.PI) * angle} degrees) = {value}");
    }
}

Output

Sine (-30 degrees) = -0.5

Conclusion

In this C# Tutorial, we have learnt the syntax of C# Math.Sin() method, and also learnt how to use this method with the help of C# example programs.