
- 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
Math Class Fields with Examples in C#
The Math class in C# has Math.E and Math.PI fields. Let us see an example of both the fields −
Math.E
Syntax
It is the natural logarithmic base specified by the constant e. The syntax is as follows −
public const double E = 2.71828182845905;
Example
Let us now see an example −
using System; public class Demo{ public static void Main(){ double d = Math.E; Console.WriteLine("Math.E = " + d); } }
Output
This will produce the following output −
Math.E = 2.71828182845905
Math.PI
The Math.PI field represents the ratio of the circumference of a circle to its diameter, specified by the constant, π.
Syntax
The syntax is as follows −
public const double PI = 3.14159265358979;
Example
Let us now see an example −
using System; public class Demo{ public static void Main(){ double d = Math.PI; Console.WriteLine("Math.PI = " + d); } }
Output
This will produce the following output −
Math.PI = 3.14159265358979
- Related Articles
- Math Class in C#
- Math class methods in C#
- Byte Class Fields in Java with example
- Math class methods in Java Programming
- Static import the Math Class Methods in Java
- Use static Import for sqrt() and pow() methods in class Math in Java
- How To Do Math With Lists in python ?
- Get all declared fields from a class in Java
- How to plot 2D math vectors with Matplotlib?
- Java multiplyExact() in Math
- Math. fround() function in JavaScript
- Math. hypot() function in JavaScript
- Math operations for BigDecimal in Java
- Math Operations on BigInteger in Java
- What is math object in JavaScript?

Advertisements