C# 中的 SByte.GetTypeCode 方法及示例
C# 中的 SByte.GetTypeCode() 方法用于返回值类型 SByte 的 TypeCode。
语法
语法如下 −
public TypeCode GetTypeCode ();
示例
现在让我们看一个示例 −
using System;
public class Demo {
public static void Main() {
sbyte s1 = 55;
object s2 = (sbyte)55;
Console.WriteLine("Value of S1 = "+s1);
Console.WriteLine("Value of S2 = "+s2);
int res = s1.CompareTo(s2);
if (res > 0)
Console.WriteLine("s1 > s2");
else if (res < 0)
Console.WriteLine("s1 < s2");
else
Console.WriteLine("s1 = s2");
Console.WriteLine("HashCode for s1 = "+s1.GetHashCode());
Console.WriteLine("GetTypeCode for s1 = "+s1.GetTypeCode());
Console.WriteLine("HashCode for s2 = "+s2.GetHashCode());
}
}输出
这将产生以下输出 −
Value of S1 = 55 Value of S2 = 55 s1 = s2 HashCode for s1 = 14135 GetTypeCode for s1 = SByte HashCode for s2 = 14135
示例
现在让我们看另一个示例 −
using System;
public class Demo {
public static void Main() {
sbyte s1 = 10;
sbyte s2 = 100;
Console.WriteLine("Value of S1 = "+s1);
Console.WriteLine("Value of S2 = "+s2);
int res = s1.CompareTo(s2);
if (res > 0)
Console.WriteLine("s1 > s2");
else if (res < 0)
Console.WriteLine("s1 < s2");
else
Console.WriteLine("s1 = s2");
Console.WriteLine("HashCode for s1 = "+s1.GetHashCode());
Console.WriteLine("GetTypeCode for s1 = "+s1.GetTypeCode());
Console.WriteLine("HashCode for s2 = "+s2.GetHashCode());
Console.WriteLine("GetTypeCode for s2 = "+s2.GetTypeCode());
}
}输出
这将产生以下输出 −
Value of S1 = 10 Value of S2 = 100 s1 < s2 HashCode for s1 = 2570 GetTypeCode for s1 = SByte HashCode for s2 = 25700 GetTypeCode for s2 = SByte
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP