System.Data.SqlTypes.SqlByte.CompareTo C# (CSharp) Метод

CompareTo() публичный Метод

public CompareTo ( SqlByte value ) : int
value SqlByte
Результат int
        public int CompareTo(SqlByte 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

SqlByte::CompareTo ( object value ) : int

Usage Example

Пример #1
0
		public void CompareTo()
		{

			SqlByte TestByte13 = new SqlByte(13);
			SqlByte TestByte10 = new SqlByte(10);
			SqlByte TestByte10II = new SqlByte(10);

			SqlString TestString = new SqlString("This is a test");
			
			Assert.IsTrue (TestByte13.CompareTo(TestByte10) > 0, "CompareTo method 1" + Error);
			Assert.IsTrue (TestByte10.CompareTo(TestByte13) < 0, "CompareTo method 2" + Error);
			Assert.IsTrue (TestByte10.CompareTo(TestByte10II) == 0, "CompareTo method 3" + Error);
			
			try {
				TestByte13.CompareTo(TestString);
				Assert.Fail("CompareTo method 4" + Error);
			} catch(Exception e) {
				Assert.AreEqual(typeof(ArgumentException), e.GetType(), "Parse method 5" + Error);
			}
			
		}
All Usage Examples Of System.Data.SqlTypes.SqlByte::CompareTo