
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
MathF.Tan() Method in C# with Examples
The MathF.Tan() method in C# is used to return the tangent of a given float value argument.
Syntax
Following is the syntax −
public static float Tan (float val);
Above, Val is the angle whose tangent is to be returned.
Example
Let us now see an example to implement the MathF.Tan() 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.Tan(val1) = 0.6483608 MathF.Tan(val2) = NaN
Example
Let us now see another example to implement the MathF.Tan() 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.Tan(val1) = "+MathF.Tan(val1)); Console.WriteLine("MathF.Tan(val2) = "+MathF.Tan(val2)); Console.WriteLine("MathF.Tan(val3) = "+MathF.Tan(val3)); } }
Output
This will produce the following output −
MathF.Tan(val1) = NaN MathF.Tan(val2) = NaN MathF.Tan(val3) = 0.3639702
- Related Articles
- MathF.Tanh() Method in C# with Examples
- MathF.Truncate() Method in C# with Examples
- MathF.Sin() Method in C# with Examples
- MathF.Sinh() Method in C# with Examples
- MathF.Sqrt() Method in C# with Examples
- Decimal.GetHashCode() Method in C# with Examples
- Decimal.GetTypeCode() Method in C# with Examples
- Char.GetHashCode() Method with Examples in C#
- Char.GetTypeCode() Method with Examples in C#
- MathF.Round() Method in C# with Examples
- MathF.Sign() Method in C# with Examples
- MathF.Atanh() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- MathF.Acos() Method in C# with Examples
- MathF.Atan2() Method in C# with Examples

Advertisements