C# 中的 UInt64.ToString() 方法及其示例
C# 中的 UInt64.ToString() 方法用於將當前 UInt64 例項的數字值轉換為等效的字串表示形式。
語法
以下是語法 -
public override string ToString();
public string ToString()
示例
using System;
public class Demo {
public static void Main(){
ulong val1 = 465656665;
ulong val2 = 232525678;
Console.WriteLine("Value1 (String representation) = "+val1.ToString());
Console.WriteLine("Value2 (String representation) = "+val2.ToString());
bool res = val1.Equals(val2);
Console.WriteLine("Return value (comparison) = "+res);
if (res)
Console.WriteLine("val1 = val2");
else
Console.WriteLine("val1 != val2");
}
}現在讓我們看一個示例,以實現 UInt64.ToString() 方法 -
C#
Value1 (String representation) = 465656665 Value2 (String representation) = 232525678 Return value (comparison) = False val1 != val2
public string ToString()
輸出
using System;
public class Demo {
public static void Main(){
ulong val1 = 0;
ulong val2 = UInt64.MaxValue;
Console.WriteLine("Value1 (String representation) = "+val1.ToString());
Console.WriteLine("Value2 (String representation) = "+val2.ToString());
bool res = val1.Equals(val2);
Console.WriteLine("Return value (comparison) = "+res);
if (res)
Console.WriteLine("val1 = val2");
else
Console.WriteLine("val1 != val2");
}
}現在讓我們看一個示例,以實現 UInt64.ToString() 方法 -
C#
Value1 (String representation) = 0 Value2 (String representation) = 18446744073709551615 Return value (comparison) = False val1 != val2
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP