SByte - Abs
Returns the absolute value of an 8-bit signed integer.
public static void Main() { sbyte[] values = { -127, -35, 0, 1, 7, 30, 127 }; Console.WriteLine("{0,10}{1,10}","SByte", "Abs"); Console.WriteLine("{0,10}{1,10}","-----", "---"); foreach (Int16 value in values) { // C# Extension Method: SByte - Abs Console.WriteLine("{0,10}{1,10}", value, value.Abs()); } }
View Source
using System; public static partial class Extensions { /// <summary> /// Returns the absolute value of an 8-bit signed integer. /// </summary> /// <param name="value">A number that is greater than , but less than or equal to .</param> /// <returns>An 8-bit signed integer, x, such that 0 ? x ?.</returns> public static SByte Abs(this SByte value) { return Math.Abs(value); } }