|
楼主 |
发表于 2020-7-26 11:45:01
|
显示全部楼层
看来只能如此写了.我看了一下整数表有如下的一些类型:
sbyte byte char short ushort int uint long ulong
要知道它们所对应的零值,只能用如下的方法来写了:
if (object.Equals(obj, (sbyte)0) || object.Equals(obj, (byte)0) || object.Equals(obj, (char)0) || object.Equals(obj, (short)0) || object.Equals(obj, (ushort)0) || object.Equals(obj, (int)0) || object.Equals(obj, (uint)0) || object.Equals(obj, (long)0) || object.Equals(obj, (ulong)0))
{
System.Console.WriteLine("零值");
}
else
{
System.Console.WriteLine("非零值");
}
|
|