Int32 - Sign

Returns a value indicating the sign of a 32-bit signed integer.

Try it

public static void Main()
{
	string str = "{0,6} is {1} zero.";
	
    Int32[] values = { 7, 32767, 758, 0, -456, -12, -2, -32767 };

    foreach (Int32 value in values)
    {
		// C# Extension Method: Int32 - Sign
        Console.WriteLine(str, value, Display(value.Sign()));
    }
}

public static String Display(int compare)
{
	if (compare == 0) 
    	return "equal to";
	else if (compare < 0)  
    	return "less than";
	else 
    	return "greater than";
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Returns a value indicating the sign of a 32-bit signed integer.
    /// </summary>
    /// <param name="value">A signed number.</param>
    /// <returns>
    ///     A number that indicates the sign of , as shown in the following table.Return value Meaning -1  is less than
    ///     zero. 0  is equal to zero. 1  is greater than zero.
    /// </returns>
    public static Int32 Sign(this Int32 value)
    {
        return Math.Sign(value);
    }
}