MathF.Sin() Method in C# with Examples


The MathF.Sin() method in C# is used to return the sine of a given float value argument.

Syntax

Following is the syntax −

public static float Sin (float val);

Above, Val is the angle whose sine is to be returned.

Example

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

using System;
public class Demo {
   public static void Main(){
      float val1 = 10f;
      float val2 = float.NaN;
      Console.WriteLine("MathF.Tan(val1) = "+MathF.Tan(val1));
      Console.WriteLine("MathF.Tan(val2) = "+MathF.Tan(val2));
   }
}

Output

This will produce the following output −

MathF.Sign(val1) = -0.5440211
MathF.Sign(val2) = NaN

Example

Let us now see another example to implement the MathF.Sin() method −

using System;
public class Demo {
   public static void Main(){
      float val1 = float.PositiveInfinity;
      float val2 = float.NegativeInfinity;
      float val3 = (20f * (MathF.PI)) / 180;
      Console.WriteLine("MathF.Sin(val1) = "+MathF.Sin(val1));
      Console.WriteLine("MathF.Sin(val2) = "+MathF.Sin(val2));
      Console.WriteLine("MathF.Sin(val3) = "+MathF.Sin(val3));
   }
}

Output

This will produce the following output −

MathF.Sin(val1) = NaN
MathF.Sin(val2) = NaN
MathF.Sin(val3) = 0.3420202

Updated on: 07-Nov-2019

106 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements