本文整理汇总了C#中System.Data.SqlTypes.SqlInt16.ToSqlDecimal方法的典型用法代码示例。如果您正苦于以下问题:C# SqlInt16.ToSqlDecimal方法的具体用法?C# SqlInt16.ToSqlDecimal怎么用?C# SqlInt16.ToSqlDecimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlTypes.SqlInt16
的用法示例。
在下文中一共展示了SqlInt16.ToSqlDecimal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSqlDecimal
/// <summary>
/// Converts the value of the specified SqlInt16 to its equivalent SqlDecimal representation.
/// </summary>
/// <param name="value">An SqlInt16.</param>
/// <returns>The equivalent SqlDecimal.</returns>
public static SqlDecimal ToSqlDecimal(SqlInt16 value) { return value.ToSqlDecimal(); }
示例2: Conversions
public void Conversions()
{
SqlInt16 Test12 = new SqlInt16 (12);
SqlInt16 Test0 = new SqlInt16 (0);
SqlInt16 TestNull = SqlInt16.Null;
SqlInt16 Test1000 = new SqlInt16 (1000);
SqlInt16 Test288 = new SqlInt16(288);
// ToSqlBoolean ()
Assert ("TestA#1", Test12.ToSqlBoolean ().Value);
Assert ("TestA#2", !Test0.ToSqlBoolean ().Value);
Assert ("TestA#3", TestNull.ToSqlBoolean ().IsNull);
// ToSqlByte ()
AssertEquals ("TestB#1", (byte)12, Test12.ToSqlByte ().Value);
AssertEquals ("TestB#2", (byte)0, Test0.ToSqlByte ().Value);
try {
SqlByte b = (byte)Test1000.ToSqlByte ();
Fail ("TestB#4");
} catch (Exception e) {
AssertEquals ("TestB#5", typeof (OverflowException), e.GetType ());
}
// ToSqlDecimal ()
AssertEquals ("TestC#1", (decimal)12, Test12.ToSqlDecimal ().Value);
AssertEquals ("TestC#2", (decimal)0, Test0.ToSqlDecimal ().Value);
AssertEquals ("TestC#3", (decimal)288, Test288.ToSqlDecimal ().Value);
// ToSqlDouble ()
AssertEquals ("TestD#1", (double)12, Test12.ToSqlDouble ().Value);
AssertEquals ("TestD#2", (double)0, Test0.ToSqlDouble ().Value);
AssertEquals ("TestD#3", (double)1000, Test1000.ToSqlDouble ().Value);
// ToSqlInt32 ()
AssertEquals ("TestE#1", (int)12, Test12.ToSqlInt32 ().Value);
AssertEquals ("TestE#2", (int)0, Test0.ToSqlInt32 ().Value);
AssertEquals ("TestE#3", (int)288, Test288.ToSqlInt32().Value);
// ToSqlInt64 ()
AssertEquals ("TestF#1", (long)12, Test12.ToSqlInt64 ().Value);
AssertEquals ("TestF#2", (long)0, Test0.ToSqlInt64 ().Value);
AssertEquals ("TestF#3", (long)288, Test288.ToSqlInt64 ().Value);
// ToSqlMoney ()
AssertEquals ("TestG#1", 12.0000M, Test12.ToSqlMoney ().Value);
AssertEquals ("TestG#2", (decimal)0, Test0.ToSqlMoney ().Value);
AssertEquals ("TestG#3", 288.0000M, Test288.ToSqlMoney ().Value);
// ToSqlSingle ()
AssertEquals ("TestH#1", (float)12, Test12.ToSqlSingle ().Value);
AssertEquals ("TestH#2", (float)0, Test0.ToSqlSingle ().Value);
AssertEquals ("TestH#3", (float)288, Test288.ToSqlSingle().Value);
// ToSqlString ()
AssertEquals ("TestI#1", "12", Test12.ToSqlString ().Value);
AssertEquals ("TestI#2", "0", Test0.ToSqlString ().Value);
AssertEquals ("TestI#3", "288", Test288.ToSqlString ().Value);
// ToString ()
AssertEquals ("TestJ#1", "12", Test12.ToString ());
AssertEquals ("TestJ#2", "0", Test0.ToString ());
AssertEquals ("TestJ#3", "288", Test288.ToString ());
}
示例3: ToSqlDecimal
/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlDecimal</c> value.</summary>
public static SqlDecimal ToSqlDecimal(SqlInt16 p) { return p.ToSqlDecimal(); }
示例4: Conversions
public void Conversions()
{
SqlInt16 Test12 = new SqlInt16(12);
SqlInt16 Test0 = new SqlInt16(0);
SqlInt16 TestNull = SqlInt16.Null;
SqlInt16 Test1000 = new SqlInt16(1000);
SqlInt16 Test288 = new SqlInt16(288);
// ToSqlBoolean ()
Assert.True(Test12.ToSqlBoolean().Value);
Assert.True(!Test0.ToSqlBoolean().Value);
Assert.True(TestNull.ToSqlBoolean().IsNull);
// ToSqlByte ()
Assert.Equal((byte)12, Test12.ToSqlByte().Value);
Assert.Equal((byte)0, Test0.ToSqlByte().Value);
try
{
SqlByte b = (byte)Test1000.ToSqlByte();
Assert.False(true);
}
catch (OverflowException e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlDecimal ()
Assert.Equal(12, Test12.ToSqlDecimal().Value);
Assert.Equal(0, Test0.ToSqlDecimal().Value);
Assert.Equal(288, Test288.ToSqlDecimal().Value);
// ToSqlDouble ()
Assert.Equal(12, Test12.ToSqlDouble().Value);
Assert.Equal(0, Test0.ToSqlDouble().Value);
Assert.Equal(1000, Test1000.ToSqlDouble().Value);
// ToSqlInt32 ()
Assert.Equal(12, Test12.ToSqlInt32().Value);
Assert.Equal(0, Test0.ToSqlInt32().Value);
Assert.Equal(288, Test288.ToSqlInt32().Value);
// ToSqlInt64 ()
Assert.Equal(12, Test12.ToSqlInt64().Value);
Assert.Equal(0, Test0.ToSqlInt64().Value);
Assert.Equal(288, Test288.ToSqlInt64().Value);
// ToSqlMoney ()
Assert.Equal(12.0000M, Test12.ToSqlMoney().Value);
Assert.Equal(0, Test0.ToSqlMoney().Value);
Assert.Equal(288.0000M, Test288.ToSqlMoney().Value);
// ToSqlSingle ()
Assert.Equal(12, Test12.ToSqlSingle().Value);
Assert.Equal(0, Test0.ToSqlSingle().Value);
Assert.Equal(288, Test288.ToSqlSingle().Value);
// ToSqlString ()
Assert.Equal("12", Test12.ToSqlString().Value);
Assert.Equal("0", Test0.ToSqlString().Value);
Assert.Equal("288", Test288.ToSqlString().Value);
// ToString ()
Assert.Equal("12", Test12.ToString());
Assert.Equal("0", Test0.ToString());
Assert.Equal("288", Test288.ToString());
}