C#中的Boolean.GetTypeCode()方法用於返回布爾值類型的類型代碼。
用法
語法如下 -
public TypeCode GetTypeCode ();
示例
現在讓我們看一個例子 -
using System;
public class Demo {
public static void Main(String[] args){
string str = "JackSparrow!";
bool val = true;
char[] arr = { 'J', 'a'};
Console.WriteLine("String = "+str);
Console.WriteLine("String (after trim) = " + str.Trim(arr));
Console.WriteLine("String (Hashcode) = "+str.GetHashCode());
Console.WriteLine("Bool (Hashcode) = "+val.GetHashCode());
Console.WriteLine("Bool (TypeCode) = "+val.GetTypeCode());
}
}
輸出
這將產生以下輸出 -
String = JackSparrow! String (after trim) = ckSparrow! String (Hashcode) = -203134198 Bool (Hashcode) = 1 Bool (TypeCode) = Boolean
示例
現在讓我們看另一個例子 -
using System;
public class Demo {
public static void Main(String[] args){
bool val1 = true;
bool val2 = false;
Console.WriteLine("Value1 (Hashcode) = "+val1.GetHashCode());
Console.WriteLine("Value1 (TypeCode) = "+val1.GetTypeCode());
Console.WriteLine("Value2 (Hashcode) = "+val2.GetHashCode());
Console.WriteLine("Value2 (TypeCode) = "+val2.GetTypeCode());
}
}
輸出
這將產生以下輸出 -
Value1 (Hashcode) = 1 Value1 (TypeCode) = Boolean Value2 (Hashcode) = 0 Value2 (TypeCode) = Boolean
相關用法
- C# Boolean.GetTypeCode用法及代碼示例
- C# Boolean.GetHashCode()用法及代碼示例
- C# Boolean.ToString()用法及代碼示例
- C# Boolean.CompareTo(Boolean)用法及代碼示例
- C# Boolean.Equals(Object)用法及代碼示例
- C# Boolean.TryParse()用法及代碼示例
- C# Boolean.CompareTo(Object)用法及代碼示例
- C# Boolean.Parse()用法及代碼示例
- C# Boolean.ToString(IFormatProvider)用法及代碼示例
- C# Boolean.Equals(Boolean)用法及代碼示例
- C# BitConverter.ToChar()用法及代碼示例
- C# Byte.Equals(Byte)用法及代碼示例
- C# Byte.CompareTo(Byte)用法及代碼示例
- C# BitConverter.ToUInt32用法及代碼示例
- C# BitConverter.ToSingle()用法及代碼示例
- C# BitConverter.ToUInt64用法及代碼示例
- C# BitConverter.ToDouble()用法及代碼示例
- C# BitConverter.ToInt32()用法及代碼示例
- C# BitConverter.ToString(Byte[])用法及代碼示例
- C# Byte.Equals(Object)用法及代碼示例
注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 Boolean.GetTypeCode() Method in C# with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。