![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements