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


C# Decimal.Implicit操作符代码示例

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


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

示例1: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of 32-bit unsigned integer values.
        uint[] values = { uint.MinValue, uint.MaxValue, 0xFFFFFF,
                          123456789, 4000000000 };
        // Convert each value to a Decimal.
        foreach (var value in values) {
           Decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:19,代码来源:Decimal.Implicit

输出:

0 (UInt32) --> 0 (Decimal)
4294967295 (UInt32) --> 4294967295 (Decimal)
16777215 (UInt32) --> 16777215 (Decimal)
123456789 (UInt32) --> 123456789 (Decimal)
4000000000 (UInt32) --> 4000000000 (Decimal)

示例2: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of 16-bit unsigned integer values.
        ushort[] values = { ushort.MinValue, ushort.MaxValue,     
                            0xFFF, 12345, 40000 };
        // Convert each value to a Decimal.
        foreach (var value in values) {
           Decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:19,代码来源:Decimal.Implicit

输出:

0 (UInt16) --> 0 (Decimal)
65535 (UInt16) --> 65535 (Decimal)
4095 (UInt16) --> 4095 (Decimal)
12345 (UInt16) --> 12345 (Decimal)
40000 (UInt16) --> 40000 (Decimal)

示例3: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of 8-bit signed integer values.
        sbyte[] values = { sbyte.MinValue, sbyte.MaxValue,     
                           0x3F, 123, -100 };
        // Convert each value to a Decimal.
        foreach (var value in values) {
           Decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:19,代码来源:Decimal.Implicit

输出:

-128 (SByte) --> -128 (Decimal)
127 (SByte) --> 127 (Decimal)
63 (SByte) --> 63 (Decimal)
123 (SByte) --> 123 (Decimal)
-100 (SByte) --> -100 (Decimal)

示例4: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of 64-bit integer values.
        long[] values = { long.MinValue, long.MaxValue, 
                          0xFFFFFFFFFFFF, 123456789123456789,
                          -1000000000000000 };
        // Convert each value to a Decimal.
        foreach (var value in values) {
           Decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:20,代码来源:Decimal.Implicit

输出:

-9223372036854775808 (Int64) --> -9223372036854775808 (Decimal)
9223372036854775807 (Int64) --> 9223372036854775807 (Decimal)
281474976710655 (Int64) --> 281474976710655 (Decimal)
123456789123456789 (Int64) --> 123456789123456789 (Decimal)
-1000000000000000 (Int64) --> -1000000000000000 (Decimal)

示例5: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of byte values.
        byte[] values = { byte.MinValue, byte.MaxValue, 
                          0x3F, 123, 200 };   
        // Convert each value to a Decimal.
        foreach (var value in values) {
           decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:19,代码来源:Decimal.Implicit

输出:

0 (Byte) --> 0 (Decimal)
255 (Byte) --> 255 (Decimal)
63 (Byte) --> 63 (Decimal)
123 (Byte) --> 123 (Decimal)
200 (Byte) --> 200 (Decimal)

示例6: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of 16-bit integer values.
        short[] values = { short.MinValue, short.MaxValue, 
                           0xFFF, 12345, -10000 };   
        // Convert each value to a Decimal.
        foreach (var value in values) {
           Decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:19,代码来源:Decimal.Implicit

输出:

-32768 (Int16) --> -32768 (Decimal)
32767 (Int16) --> 32767 (Decimal)
4095 (Int16) --> 4095 (Decimal)
12345 (Int16) --> 12345 (Decimal)
-10000 (Int16) --> -10000 (Decimal)

示例7: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of Char values.
        Char[] values = { '\0', ' ', '*', 'A', 'a', '{', 'Æ' };

        // Convert each Char value to a Decimal.
        foreach (var value in values) {
           decimal decValue = value;
           Console.WriteLine("'{0}' ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:19,代码来源:Decimal.Implicit

输出:

' ' (Char) --> 0 (Decimal)
' ' (Char) --> 32 (Decimal)
'*' (Char) --> 42 (Decimal)
'A' (Char) --> 65 (Decimal)
'a' (Char) --> 97 (Decimal)
'{' (Char) --> 123 (Decimal)
'Æ' (Char) --> 198 (Decimal)

示例8: Main

//引入命名空间
using System;

public class Example
{
    public static void Main()
    {
        // Define an array of 64-bit unsigned integer values.
        ulong[] values = { ulong.MinValue, ulong.MaxValue, 
                           0xFFFFFFFFFFFF, 123456789123456789, 
                           1000000000000000 };
        // Convert each value to a Decimal.
        foreach (var value in values) {
           Decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:20,代码来源:Decimal.Implicit

输出:

0 (UInt64) --> 0 (Decimal)
18446744073709551615 (UInt64) --> 18446744073709551615 (Decimal)
281474976710655 (UInt64) --> 281474976710655 (Decimal)
123456789123456789 (UInt64) --> 123456789123456789 (Decimal)
1000000000000000 (UInt64) --> 1000000000000000 (Decimal)

示例9: Main

//引入命名空间
using System;

class Example
{
    public static void Main()
    {
        // Define an array of 32-bit integer values.
        int[] values = { int.MinValue, int.MaxValue, 0xFFFFFF,
                         123456789, -1000000000 };
        // Convert each value to a Decimal.
        foreach (var value in values) {
           Decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:19,代码来源:Decimal.Implicit

输出:

-2147483648 (Int32) --> -2147483648 (Decimal)
2147483647 (Int32) --> 2147483647 (Decimal)
16777215 (Int32) --> 16777215 (Decimal)
123456789 (Int32) --> 123456789 (Decimal)
-1000000000 (Int32) --> -1000000000 (Decimal)


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