此方法用於返回值類型Byte的TypeCode。
用法:
public TypeCode GetTypeCode ();
返回值:它返回枚舉常量Byte。
以下示例程序旨在說明Byte.GetTypeCode()方法的使用:
示例1:
// C# program to demonstrate
// Byte.GetTypeCode() Method
using System;
class GFG {
// Main Method
public static void Main()
{
// Declaring val1 and val2
byte val1;
bool val2;
// intializing the
// val1 and val2
val1 = 12;
val2 = true;
// getting TypeCode
// using GetTypeCode() method
TypeCode t1 = val1.GetTypeCode();
TypeCode t2 = val2.GetTypeCode();
// Display TypeCode
Console.WriteLine("TypeCode of val1 is {0}", t1);
Console.WriteLine("TypeCode of val2 is {0}", t2);
}
}
輸出:
TypeCode of val1 is Byte TypeCode of val2 is Boolean
示例2:
// C# program to demonstrate
// Byte.GetTypeCode() Method
using System;
class GFG {
// Main Method
public static void Main()
{
// Declaring val1 and val2
byte val1;
bool val2;
// intializing the
// val1 and val2
val1 = 12;
val2 = true;
// calling get() method
get(val1);
get(val2);
}
// Defining the get() method
public static void get(byte val)
{
// getting TypeCode
// using GetTypeCode() method
TypeCode t = val.GetTypeCode();
// Display the TypeCode
Console.WriteLine("TypeCode of {0} is {1}", val, t);
}
public static void get(bool val)
{
// getting TypeCode
// using GetTypeCode() method
TypeCode t = val.GetTypeCode();
// Display the TypeCode
Console.WriteLine("TypeCode of {0} is {1}", val, t);
}
}
輸出:
TypeCode of 12 is Byte TypeCode of True is Boolean
參考:
相關用法
- C# DateTimeOffset.Add()用法及代碼示例
- C# String.Contains()用法及代碼示例
- C# Math.Sin()用法及代碼示例
- C# Math.Cos()用法及代碼示例
- C# Dictionary.Add()用法及代碼示例
- C# Math.Tan()用法及代碼示例
- C# Math.Abs()方法用法及代碼示例
- C# Math.Exp()用法及代碼示例
- C# Math.Abs()函數用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 C# | Byte.GetTypeCode() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。