System.Data.SqlTypes.SqlSingle.CompareTo C# (CSharp) Method

CompareTo() public method

public CompareTo ( SqlSingle value ) : int
value SqlSingle
return int
        public int CompareTo(SqlSingle value)
        {
            // If both Null, consider them equal.
            // Otherwise, Null is less than anything.
            if (IsNull)
                return value.IsNull ? 0 : -1;
            else if (value.IsNull)
                return 1;

            if (this < value) return -1;
            if (this > value) return 1;
            return 0;
        }

Same methods

SqlSingle::CompareTo ( object value ) : int

Usage Example

                public void CompareTo()
                {
                        SqlSingle Test1 = new SqlSingle (4E+30);
                        SqlSingle Test11 = new SqlSingle (4E+30);
                        SqlSingle Test2 = new SqlSingle (-9E+30);
                        SqlSingle Test3 = new SqlSingle (10000);
                        SqlString TestString = new SqlString ("This is a test");

                        Assert.IsTrue (Test1.CompareTo (Test3) > 0, "#E01");
                        Assert.IsTrue (Test2.CompareTo (Test3) < 0, "#E02");
                        Assert.IsTrue (Test1.CompareTo (Test11) == 0, "#E03");
                        Assert.IsTrue (Test11.CompareTo (SqlSingle.Null) > 0, "#E04");

                        try {
                                Test1.CompareTo (TestString);
                                Assert.Fail("#E05");
                        } catch(Exception e) {
                                Assert.AreEqual (typeof (ArgumentException), e.GetType (), "#E06");
                        }
                }
All Usage Examples Of System.Data.SqlTypes.SqlSingle::CompareTo