Posted by : Anwar Hossain
Category : asp.net c # basic tutorial

How to Use C Sharp Math Class

Dear viewers I will explain and give some example of common Math class’s methods. In our real project some times we need to do many typs of mathmetical operations so these operations can be easily implemented by Math class of System namespace. Most of Math class’s Method are static to implement.

C Sharp Math Class Example


C Sharp Math Class Example


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

 

namespace Csharp_MathClass

{

    class Program

    {

        static void Main(string[] args)

        {

          

                Console.WriteLine("\n Returns a specified number raised to the specified power");

 

                double pow = Math.Pow(25, 25);

                Console.WriteLine("\n {0}", pow);

 

                Console.WriteLine("\n Rounds a decimal value to the nearest integral value.");

 

                double round = Math.Round(35.68743);

                Console.WriteLine("\n {0}", round);

 

 

                Console.WriteLine("\n Returns the smaller of two  numbers.");

 

                double Min = Math.Min(44, 49);

                Console.WriteLine("\n {0}", Min);

 

                Console.WriteLine("\n Returns the Maximum of two  numbers.");

 

                double Max = Math.Max(40, 70);

                Console.WriteLine("\n {0}", Max);

 

 

                Console.WriteLine("\n Returns rounds the given value to the nearest larger integer.");

 

                double Cell = Math.Ceiling(33.47);

                Console.WriteLine("\n {0}",Cell);

 

                Console.WriteLine("\n provides absolute of given value."); 

                Console.WriteLine("\n {0}",Math.Abs(34.4));

                Console.WriteLine("\n {0}",Math.Abs(-34.4));

                Console.WriteLine("\n {0}",Math.Abs(0));

                Console.WriteLine("\n provides Cosine value for given radians");

                Console.WriteLine("\n {0}", Math.Cos(30));

                Console.WriteLine("\n It gives the Sin value of given input.");

                Console.WriteLine("\n {0}", Math.Sin(22));

                Console.WriteLine("\n It gives the Tan of given input.");

                Console.WriteLine("\n {0}", Math.Tan(14));

                Console.WriteLine("\n gives the exponential of given value");

                Console.WriteLine("\n {0}", Math.Exp(5.4));

                Console.WriteLine("\n It gives the square root of given input.");

                Console.WriteLine("\n {0}", Math.Sqrt(64));

 

                Console.ReadKey();   

 

        }

    }

}


Output


C_Sharp_Math_Class_Example



Realted Article Headline

How to find odd number in c #
How to generate random number in c #
Nested For Loop Example in C Sharp
Store C sharp reference type in a List C#
Find number of items in a List C#
Concept about C # List
Custom Time formatting example C #
Custom Date formatting example C #
String Format Example using ASP.Net C#
Simple enum example in C Sharp
Nested switch-case statement example in C #
Combined switch...case statement example in C #
C Sharp switch case statement Example
C# SUM ArrayList Element Example
C# String Class Methods Example
C Sharp String Class Properties and Methods
C Sharp String Class Example
How to join two ArrayList collections in C#.
How to Use C Sharp Math Class
C Sharp ArrayList Property and Method
C Sharp ArrayList Example
C Sharp Arrays Example
C Sharp Logical operator Example
C Sharp Relational operators
C Sharp Arithmetic operators Example
C Sharp Common Assignment Operator
Simple for loop example in c sharp

Article Category

How to create asp.net control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in asp.net c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C#
asp.net c # basic tutorial
How to use ajax toolkit in asp.net C#
How to use different types of validation control using asp.net c#
How to use grid view in asp.net c#
Protected by Copyscape Online Plagiarism Detection