当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


C# Double.GetTypeCode()用法及代码示例


Double.GetTypeCode()方法用于返回值类型Double的TypeCode。

用法: public TypeCode GetTypeCode ();

返回值:此方法返回枚举常量Double。


下面的程序说明Double.GetTypeCode()方法的使用:

示例1:

// C# program to demonstrate the 
// Double.GetTypeCode() 
// Method 
using System; 
using System.Globalization; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
  
        // Declaring and initializing value1 
        double value1 = 10d; 
  
        // getting the typeCode 
        // using GetTypeCode() method 
        TypeCode value = value1.GetTypeCode(); 
  
        // Display the TypeCode 
        Console.WriteLine("TypeCode is {0}", value); 
    } 
}
输出:
TypeCode is Double

示例2:

// C# program to demonstrate the 
// Double.GetTypeCode() 
// Method 
using System; 
using System.Globalization; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
        // calling get() method 
        get(5d); 
        get(5.5d); 
        get(10d); 
        get(7.5d); 
    } 
  
    // defining get() method 
    public static void get(double value1) 
    { 
  
        // getting the TypeCode 
        // using GetTypeCode() method 
        TypeCode value = value1.GetTypeCode(); 
  
        // Display the TypeCode 
        Console.WriteLine("TypeCode is {0}", value); 
    } 
}
输出:
TypeCode is Double
TypeCode is Double
TypeCode is Double
TypeCode is Double

参考:



相关用法


注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 Double.GetTypeCode() Method in C#。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。