C# 中 UInt32.ToString() 方法含示例
C# 中的 UInt32.ToString() 方法用于将 UInt32 当前实例的数字值转换为其等效的字符串表示形式。
语法
以下是语法 −
public override string ToString();
示例
现在让我们看一个实现 UInt32.ToString() 方法的示例 −
using System;
public class Demo {
public static void Main(){
uint val1 = 100;
uint val2 = 80;
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");
}
}输出
这将生成如下输出 −
Value1 (String representation) = 100 Value2 (String representation) = 80 Return value (comparison) = False val1 != val2
示例
现在让我们看另一个实现 UInt32.ToString() 方法的示例 −
using System;
public class Demo {
public static void Main(){
uint val1 = 0;
uint val2 = UInt32.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");
}
}输出
这将生成如下输出 −
Value1 (String representation) = 0 Value2 (String representation) = 4294967295 Return value (comparison) = False val1 != val2
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP