当前位置: 首页>>代码示例>>C#>>正文


C# SqlMoney.ToSqlByte方法代码示例

本文整理汇总了C#中System.Data.SqlTypes.SqlMoney.ToSqlByte方法的典型用法代码示例。如果您正苦于以下问题:C# SqlMoney.ToSqlByte方法的具体用法?C# SqlMoney.ToSqlByte怎么用?C# SqlMoney.ToSqlByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlTypes.SqlMoney的用法示例。


在下文中一共展示了SqlMoney.ToSqlByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToSqlByte

 /// <summary>
 /// Converts the value of the specified SqlMoney to its equivalent SqlByte representation.
 /// </summary>
 /// <param name="value">An SqlMoney.</param>
 /// <returns>The equivalent SqlByte.</returns>
 public static SqlByte ToSqlByte(SqlMoney value) { return value.ToSqlByte(); }
开发者ID:mstaessen,项目名称:fluorinefx,代码行数:6,代码来源:Convert.cs

示例2: Conversions

                public void Conversions()
                {		      
			SqlMoney TestMoney100 = new SqlMoney (100);

			// ToDecimal
			Assert.AreEqual ( (decimal)6464.6464, Test1.ToDecimal (), "#M01");

			// ToDouble
			Assert.AreEqual ( (double)6464.6464, Test1.ToDouble (), "#M02");

			// ToInt32
			Assert.AreEqual ( (int)90000, Test2.ToInt32 (), "#M03");
                        Assert.AreEqual ( (int)6465, Test1.ToInt32 (), "#M04");

			// ToInt64
                        Assert.AreEqual ( (long)90000, Test2.ToInt64 (), "#M05");
                        Assert.AreEqual ( (long)6465, Test1.ToInt64 (), "#M06");

                        // ToSqlBoolean ()
                        Assert.IsTrue (Test1.ToSqlBoolean ().Value, "#M07");
                        Assert.IsTrue (!SqlMoney.Zero.ToSqlBoolean ().Value, "#M08");
                        Assert.IsTrue (SqlMoney.Null.ToSqlBoolean ().IsNull, "#M09");

                        // ToSqlByte ()
                        Assert.AreEqual ( (byte)100, TestMoney100.ToSqlByte ().Value, "#M10");

                        try {
                                SqlByte b = (byte)Test2.ToSqlByte ();
                                Assert.Fail ("#M11");
                        } catch (Exception e) {
                                Assert.AreEqual ( typeof (OverflowException), e.GetType (), "#M12");
                        }

                        // ToSqlDecimal ()
                        Assert.AreEqual ( (decimal)6464.6464, Test1.ToSqlDecimal ().Value, "#M13");
                        Assert.AreEqual ( -45000.0000m, Test4.ToSqlDecimal ().Value, "#M14");

                        // ToSqlInt16 ()
                        Assert.AreEqual ( (short)6465, Test1.ToSqlInt16 ().Value, "#M15");

                        try {
                                SqlInt16 test = SqlMoney.MaxValue.ToSqlInt16().Value;
                                Assert.Fail ("#M17");
                        } catch (Exception e) {
                                Assert.AreEqual ( typeof (OverflowException), e.GetType (), "#M18");
                        }        

                        // ToSqlInt32 ()
                        Assert.AreEqual ( (int)6465, Test1.ToSqlInt32 ().Value, "#M19");
                        Assert.AreEqual ( (int)(-45000), Test4.ToSqlInt32 ().Value, "#M20");

                        try {
                                SqlInt32 test = SqlMoney.MaxValue.ToSqlInt32 ().Value;
                                Assert.Fail ("#M21");
                        } catch (Exception e) { 
                                Assert.AreEqual ( typeof (OverflowException), e.GetType (), "#M22");
                        }

                        // ToSqlInt64 ()
                        Assert.AreEqual ( (long)6465, Test1.ToSqlInt64 ().Value, "#M23");
                        Assert.AreEqual ( (long)(-45000), Test4.ToSqlInt64 ().Value, "#M24");

                        // ToSqlSingle ()
                        Assert.AreEqual ( (float)6464.6464, Test1.ToSqlSingle ().Value, "#M25");

                        // ToSqlString ()
                        Assert.AreEqual ( "6464.6464", Test1.ToSqlString ().Value, "#M26");
                        Assert.AreEqual ( "90000.00", Test2.ToSqlString ().Value, "#M27");

                        // ToString ()
                        Assert.AreEqual ( "6464.6464", Test1.ToString (), "#M28");
                        Assert.AreEqual ( "90000.00", Test2.ToString (), "#M29");
                }
开发者ID:LevNNN,项目名称:mono,代码行数:73,代码来源:SqlMoneyTest.cs

示例3: ToSqlByte

		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlMoney   p) { return p.ToSqlByte();                                              }
开发者ID:titolarz,项目名称:bltoolkit,代码行数:2,代码来源:Convert.generated.cs

示例4: Conversions

        public void Conversions()
        {
            SqlMoney TestMoney100 = new SqlMoney(100);

            // ToDecimal
            Assert.Equal((decimal)6464.6464, _test1.ToDecimal());

            // ToDouble
            Assert.Equal(6464.6464, _test1.ToDouble());

            // ToInt32
            Assert.Equal(90000, _test2.ToInt32());
            Assert.Equal(6465, _test1.ToInt32());

            // ToInt64
            Assert.Equal(90000, _test2.ToInt64());
            Assert.Equal(6465, _test1.ToInt64());

            // ToSqlBoolean ()
            Assert.True(_test1.ToSqlBoolean().Value);
            Assert.True(!SqlMoney.Zero.ToSqlBoolean().Value);
            Assert.True(SqlMoney.Null.ToSqlBoolean().IsNull);

            // ToSqlByte ()
            Assert.Equal((byte)100, TestMoney100.ToSqlByte().Value);

            try
            {
                SqlByte b = (byte)_test2.ToSqlByte();
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlDecimal ()
            Assert.Equal((decimal)6464.6464, _test1.ToSqlDecimal().Value);
            Assert.Equal(-45000.0000m, _test4.ToSqlDecimal().Value);

            // ToSqlInt16 ()
            Assert.Equal((short)6465, _test1.ToSqlInt16().Value);

            try
            {
                SqlInt16 test = SqlMoney.MaxValue.ToSqlInt16().Value;
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlInt32 ()
            Assert.Equal(6465, _test1.ToSqlInt32().Value);
            Assert.Equal(-45000, _test4.ToSqlInt32().Value);

            try
            {
                SqlInt32 test = SqlMoney.MaxValue.ToSqlInt32().Value;
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlInt64 ()
            Assert.Equal(6465, _test1.ToSqlInt64().Value);
            Assert.Equal(-45000, _test4.ToSqlInt64().Value);

            // ToSqlSingle ()
            Assert.Equal((float)6464.6464, _test1.ToSqlSingle().Value);

            // ToSqlString ()
            Assert.Equal("6464.6464", _test1.ToSqlString().Value);
            Assert.Equal("90000.00", _test2.ToSqlString().Value);

            // ToString ()
            Assert.Equal("6464.6464", _test1.ToString());
            Assert.Equal("90000.00", _test2.ToString());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:82,代码来源:SqlMoneyTest.cs


注:本文中的System.Data.SqlTypes.SqlMoney.ToSqlByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。