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


C# SqlDouble.ToSqlInt16方法代码示例

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


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

示例1: ToSqlInt16

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

示例2: Conversions

                public void Conversions()
                {
                        SqlDouble Test0 = new SqlDouble (0);
                        SqlDouble Test1 = new SqlDouble (250);
                        SqlDouble Test2 = new SqlDouble (64e64);
                        SqlDouble Test3 = new SqlDouble (64e164);
                        SqlDouble TestNull = SqlDouble.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 = Test2.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 = Test2.ToSqlMoney ().Value;
                                Fail ("#M03G");
                        } catch (Exception e) {
                                AssertEquals ("#M04G", typeof (OverflowException), e.GetType ());
                        }        

                        // ToSqlSingle ()
                        AssertEquals ("#M01H", (float)250, Test1.ToSqlSingle ().Value);
                        AssertEquals ("#M02H", (float)0, Test0.ToSqlSingle ().Value);

                        try {
                                SqlSingle test = Test2.ToSqlSingle().Value;
                                Fail ("#MO3H");
                        } catch (Exception e) {
                                AssertEquals ("#M04H", typeof (OverflowException), e.GetType ());
                        }        

                        // ToSqlString ()
                        AssertEquals ("#M01I", "250", Test1.ToSqlString ().Value);
                        AssertEquals ("#M02I", "0", Test0.ToSqlString ().Value);
                        AssertEquals ("#M03I", "6.4E+65", Test2.ToSqlString ().Value);

                        // ToString ()
                        AssertEquals ("#M01J", "250", Test1.ToString ());
                        AssertEquals ("#M02J", "0", Test0.ToString ());
                        AssertEquals ("#M03J", "6.4E+65", Test2.ToString ());
                }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:100,代码来源:SqlDoubleTest.cs

示例3: ToSqlInt16

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

示例4: Conversions

        public void Conversions()
        {
            SqlDouble Test0 = new SqlDouble(0);
            SqlDouble Test1 = new SqlDouble(250);
            SqlDouble Test2 = new SqlDouble(64e64);
            SqlDouble Test3 = new SqlDouble(64e164);
            SqlDouble TestNull = SqlDouble.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 (OverflowException 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 (OverflowException 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 (OverflowException 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 (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlInt64 ()
            Assert.Equal(250, Test1.ToSqlInt64().Value);
            Assert.Equal(0, Test0.ToSqlInt64().Value);

            try
            {
                SqlInt64 test = Test2.ToSqlInt64().Value;
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlMoney ()
            Assert.Equal(250.0000M, Test1.ToSqlMoney().Value);
            Assert.Equal(0, Test0.ToSqlMoney().Value);

            try
            {
                SqlMoney test = Test2.ToSqlMoney().Value;
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlSingle ()
            Assert.Equal(250, Test1.ToSqlSingle().Value);
            Assert.Equal(0, Test0.ToSqlSingle().Value);
//.........这里部分代码省略.........
开发者ID:dotnet,项目名称:corefx,代码行数:101,代码来源:SqlDoubleTest.cs


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