Welcome :Guest

Congratulations!!!

Top 5 Contributors of the Month
ffttt

 Home >> Forum >> C# >> Post New Question Subscribe to Forum
Author: Creative13
Posted Date: September 07, 2011     Points: 20

Hey Chandranshu,

You can do it by using Math.Abs() Method.

e.g.
`   using System;class Program{    static void Main()    {	//	// Compute two absolute values.	//	int value1 = -1000;	int value2 = 20;	int abs1 = Math.Abs(value1);	int abs2 = Math.Abs(value2);	//	// Write integral results.	//	Console.WriteLine(value1);	Console.WriteLine(abs1);	Console.WriteLine(value2);	Console.WriteLine(abs2);	//	// Compute two double absolute values.	//	double value3 = -100.123;	double value4 = 20.20;	double abs3 = Math.Abs(value3);	double abs4 = Math.Abs(value4);	//	// Write double results.	//	Console.WriteLine(value3);	Console.WriteLine(abs3);	Console.WriteLine(value4);	Console.WriteLine(abs4);    }}Output -10001000     (Absolute value)2020       (Absolute value)-100.123100.123  (Absolute value)20.220.2     (Absolute value)`