本文整理汇总了C#中System.Data.SqlTypes.SqlSingle.ToSqlByte方法的典型用法代码示例。如果您正苦于以下问题:C# SqlSingle.ToSqlByte方法的具体用法?C# SqlSingle.ToSqlByte怎么用?C# SqlSingle.ToSqlByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlTypes.SqlSingle
的用法示例。
在下文中一共展示了SqlSingle.ToSqlByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSqlByte
/// <summary>
/// Converts the value of the specified SqlSingle to its equivalent SqlByte representation.
/// </summary>
/// <param name="value">An SqlSingle.</param>
/// <returns>The equivalent SqlByte.</returns>
public static SqlByte ToSqlByte(SqlSingle value) { return value.ToSqlByte(); }
示例2: Conversions
public void Conversions()
{
SqlSingle Test0 = new SqlSingle (0);
SqlSingle Test1 = new SqlSingle (250);
SqlSingle Test2 = new SqlSingle (64E+16);
SqlSingle Test3 = new SqlSingle (64E+30);
SqlSingle TestNull = SqlSingle.Null;
// ToSqlBoolean ()
Assert ("#M01A", Test1.ToSqlBoolean ().Value);
Assert ("#M02A", !Test0.ToSqlBoolean ().Value);
Assert ("#M03A", TestNull.ToSqlBoolean ().IsNull);
// ToSqlByte ()
AssertEquals ("#M01B", (byte)250, Test1.ToSqlByte ().Value);
AssertEquals ("#M02B", (byte)0, Test0.ToSqlByte ().Value);
try {
SqlByte b = (byte)Test2.ToSqlByte ();
Fail ("#M03B");
} catch (Exception e) {
AssertEquals ("#M04B", typeof (OverflowException), e.GetType ());
}
// ToSqlDecimal ()
AssertEquals ("#M01C", 250.00000000000000M, Test1.ToSqlDecimal ().Value);
AssertEquals ("#M02C", (decimal)0, Test0.ToSqlDecimal ().Value);
try {
SqlDecimal test = Test3.ToSqlDecimal ().Value;
Fail ("#M03C");
} catch (Exception e) {
AssertEquals ("#M04C", typeof (OverflowException), e.GetType ());
}
// ToSqlInt16 ()
AssertEquals ("#M01D", (short)250, Test1.ToSqlInt16 ().Value);
AssertEquals ("#M02D", (short)0, Test0.ToSqlInt16 ().Value);
try {
SqlInt16 test = Test2.ToSqlInt16().Value;
Fail ("#M03D");
} catch (Exception e) {
AssertEquals ("#M04D", typeof (OverflowException), e.GetType ());
}
// ToSqlInt32 ()
AssertEquals ("#M01E", (int)250, Test1.ToSqlInt32 ().Value);
AssertEquals ("#M02E", (int)0, Test0.ToSqlInt32 ().Value);
try {
SqlInt32 test = Test2.ToSqlInt32 ().Value;
Fail ("#M03E");
} catch (Exception e) {
AssertEquals ("#M04E", typeof (OverflowException), e.GetType ());
}
// ToSqlInt64 ()
AssertEquals ("#M01F", (long)250, Test1.ToSqlInt64 ().Value);
AssertEquals ("#M02F", (long)0, Test0.ToSqlInt64 ().Value);
try {
SqlInt64 test = Test3.ToSqlInt64 ().Value;
Fail ("#M03F");
} catch (Exception e) {
AssertEquals ("#M04F", typeof (OverflowException), e.GetType ());
}
// ToSqlMoney ()
AssertEquals ("#M01G", 250.0000M, Test1.ToSqlMoney ().Value);
AssertEquals ("#M02G", (decimal)0, Test0.ToSqlMoney ().Value);
try {
SqlMoney test = Test3.ToSqlMoney ().Value;
Fail ("#M03G");
} catch (Exception e) {
AssertEquals ("#M04G", typeof (OverflowException), e.GetType ());
}
// ToSqlString ()
AssertEquals ("#M01H", "250", Test1.ToSqlString ().Value);
AssertEquals ("#M02H", "0", Test0.ToSqlString ().Value);
AssertEquals ("#M03H", "6.4E+17", Test2.ToSqlString ().Value);
// ToString ()
AssertEquals ("#M01I", "250", Test1.ToString ());
AssertEquals ("#M02I", "0", Test0.ToString ());
AssertEquals ("#M03I", "6.4E+17", Test2.ToString ());
}
示例3: ToSqlByte
/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlByte</c> value.</summary>
public static SqlByte ToSqlByte(SqlSingle p) { return p.ToSqlByte(); }
示例4: Conversions
public void Conversions()
{
SqlSingle Test0 = new SqlSingle(0);
SqlSingle Test1 = new SqlSingle(250);
SqlSingle Test2 = new SqlSingle(64E+16);
SqlSingle Test3 = new SqlSingle(64E+30);
SqlSingle TestNull = SqlSingle.Null;
// ToSqlBoolean ()
Assert.True(Test1.ToSqlBoolean().Value);
Assert.True(!Test0.ToSqlBoolean().Value);
Assert.True(TestNull.ToSqlBoolean().IsNull);
// ToSqlByte ()
Assert.Equal((byte)250, Test1.ToSqlByte().Value);
Assert.Equal((byte)0, Test0.ToSqlByte().Value);
try
{
SqlByte b = (byte)Test2.ToSqlByte();
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlDecimal ()
Assert.Equal(250.00000000000000M, Test1.ToSqlDecimal().Value);
Assert.Equal(0, Test0.ToSqlDecimal().Value);
try
{
SqlDecimal test = Test3.ToSqlDecimal().Value;
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlInt16 ()
Assert.Equal((short)250, Test1.ToSqlInt16().Value);
Assert.Equal((short)0, Test0.ToSqlInt16().Value);
try
{
SqlInt16 test = Test2.ToSqlInt16().Value;
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlInt32 ()
Assert.Equal(250, Test1.ToSqlInt32().Value);
Assert.Equal(0, Test0.ToSqlInt32().Value);
try
{
SqlInt32 test = Test2.ToSqlInt32().Value;
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlInt64 ()
Assert.Equal(250, Test1.ToSqlInt64().Value);
Assert.Equal(0, Test0.ToSqlInt64().Value);
try
{
SqlInt64 test = Test3.ToSqlInt64().Value;
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlMoney ()
Assert.Equal(250.0000M, Test1.ToSqlMoney().Value);
Assert.Equal(0, Test0.ToSqlMoney().Value);
try
{
SqlMoney test = Test3.ToSqlMoney().Value;
Assert.False(true);
}
catch (Exception e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlString ()
Assert.Equal("250", Test1.ToSqlString().Value);
//.........这里部分代码省略.........