本文整理汇总了C#中System.Data.SqlTypes.SqlString.ToSqlDecimal方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.ToSqlDecimal方法的具体用法?C# SqlString.ToSqlDecimal怎么用?C# SqlString.ToSqlDecimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlTypes.SqlString
的用法示例。
在下文中一共展示了SqlString.ToSqlDecimal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSqlDecimal
/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlDecimal</c> value.</summary>
public static SqlDecimal ToSqlDecimal(SqlString p) { return p.ToSqlDecimal(); }
示例2: ToSqlDecimal
// SqlTypes.
/// <summary>
/// Converts the value of the specified SqlString to its equivalent SqlDecimal representation.
/// </summary>
/// <param name="value">An SqlString.</param>
/// <returns>The equivalent SqlDecimal.</returns>
public static SqlDecimal ToSqlDecimal(SqlString value) { return value.ToSqlDecimal(); }
示例3: Conversions
public void Conversions()
{
SqlString String250 = new SqlString ("250");
SqlString String9E300 = new SqlString ("9E+300");
// ToSqlBoolean ()
Assert.IsTrue ((new SqlString("1")).ToSqlBoolean ().Value, "#O02");
Assert.IsTrue (!(new SqlString("0")).ToSqlBoolean ().Value, "#O03");
Assert.IsTrue ((new SqlString("True")).ToSqlBoolean ().Value, "#O04");
Assert.IsTrue (!(new SqlString("FALSE")).ToSqlBoolean ().Value, "#O05");
Assert.IsTrue (SqlString.Null.ToSqlBoolean ().IsNull, "#O06");
// ToSqlByte ()
Assert.AreEqual ((byte)250, String250.ToSqlByte ().Value, "#O08");
// ToSqlDateTime
Assert.AreEqual (10,
(new SqlString ("2002-10-10")).ToSqlDateTime ().Value.Day, "#O11");
// ToSqlDecimal ()
Assert.AreEqual ((decimal)250, String250.ToSqlDecimal ().Value, "#O16");
// ToSqlDouble
Assert.AreEqual ((SqlDouble)9E+300, String9E300.ToSqlDouble (), "#O19");
// ToSqlGuid
SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
Assert.AreEqual (new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid (), "#O22");
// ToSqlInt16 ()
Assert.AreEqual ((short)250, String250.ToSqlInt16 ().Value, "#O24");
// ToSqlInt32 ()
Assert.AreEqual ((int)250, String250.ToSqlInt32 ().Value, "#O27");
// ToSqlInt64 ()
Assert.AreEqual ((long)250, String250.ToSqlInt64 ().Value, "#O32");
// ToSqlMoney ()
Assert.AreEqual (250.0000M, String250.ToSqlMoney ().Value, "#O35");
// ToSqlSingle ()
Assert.AreEqual ((float)250, String250.ToSqlSingle ().Value, "#O38");
// ToString ()
Assert.AreEqual ("First TestString", Test1.ToString (), "#O41");
}
示例4: ConversionDecimalFormatException2
public void ConversionDecimalFormatException2 ()
{
SqlString String9E300 = new SqlString ("9E+300");
SqlDecimal test = String9E300.ToSqlDecimal ();
}
示例5: Conversions
public void Conversions()
{
SqlString String250 = new SqlString("250");
SqlString String9E300 = new SqlString("9E+300");
// ToSqlBoolean ()
Assert.True((new SqlString("1")).ToSqlBoolean().Value);
Assert.True(!(new SqlString("0")).ToSqlBoolean().Value);
Assert.True((new SqlString("True")).ToSqlBoolean().Value);
Assert.True(!(new SqlString("FALSE")).ToSqlBoolean().Value);
Assert.True(SqlString.Null.ToSqlBoolean().IsNull);
// ToSqlByte ()
Assert.Equal((byte)250, String250.ToSqlByte().Value);
// ToSqlDateTime
Assert.Equal(10, (new SqlString("2002-10-10")).ToSqlDateTime().Value.Day);
// ToSqlDecimal ()
Assert.Equal(250, String250.ToSqlDecimal().Value);
// ToSqlDouble
Assert.Equal(9E+300, String9E300.ToSqlDouble());
// ToSqlGuid
SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
Assert.Equal(new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid());
// ToSqlInt16 ()
Assert.Equal((short)250, String250.ToSqlInt16().Value);
// ToSqlInt32 ()
Assert.Equal(250, String250.ToSqlInt32().Value);
// ToSqlInt64 ()
Assert.Equal(250, String250.ToSqlInt64().Value);
// ToSqlMoney ()
Assert.Equal(250.0000M, String250.ToSqlMoney().Value);
// ToSqlSingle ()
Assert.Equal(250, String250.ToSqlSingle().Value);
// ToString ()
Assert.Equal("First TestString", _test1.ToString());
}
示例6: ConversionDecimalFormatException2
public void ConversionDecimalFormatException2()
{
SqlString String9E300 = new SqlString("9E+300");
Assert.Throws<FormatException>(() =>
{
SqlDecimal test = String9E300.ToSqlDecimal();
});
}
示例7: Conversions
public void Conversions()
{
SqlString String250 = new SqlString ("250");
SqlString String9E300 = new SqlString ("9E+300");
// ToSqlBoolean ()
Assert ("#O02", (new SqlString("1")).ToSqlBoolean ().Value);
Assert ("#O03", !(new SqlString("0")).ToSqlBoolean ().Value);
Assert ("#O04", (new SqlString("True")).ToSqlBoolean ().Value);
Assert ("#O05", !(new SqlString("FALSE")).ToSqlBoolean ().Value);
Assert ("#O06", SqlString.Null.ToSqlBoolean ().IsNull);
// ToSqlByte ()
AssertEquals ("#O08", (byte)250, String250.ToSqlByte ().Value);
// ToSqlDateTime
AssertEquals ("#O11", 10,
(new SqlString ("2002-10-10")).ToSqlDateTime ().Value.Day);
// ToSqlDecimal ()
AssertEquals ("#O16", (decimal)250, String250.ToSqlDecimal ().Value);
// ToSqlDouble
AssertEquals ("#O19", (SqlDouble)9E+300, String9E300.ToSqlDouble ());
// ToSqlGuid
SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
AssertEquals ("#O22", new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid ());
// ToSqlInt16 ()
AssertEquals ("#O24", (short)250, String250.ToSqlInt16 ().Value);
// ToSqlInt32 ()
AssertEquals ("#O27", (int)250, String250.ToSqlInt32 ().Value);
// ToSqlInt64 ()
AssertEquals ("#O32", (long)250, String250.ToSqlInt64 ().Value);
// ToSqlMoney ()
AssertEquals ("#O35", 250.0000M, String250.ToSqlMoney ().Value);
// ToSqlSingle ()
AssertEquals ("#O38", (float)250, String250.ToSqlSingle ().Value);
// ToString ()
AssertEquals ("#O41", "First TestString", Test1.ToString ());
}