checked(expression)与unchecked(expression)的区别C#中,关于类型转换的部分有一个问题不明白,那就是checked(expression)unchecked(expression)的区别,适用的情况,最好有小程序例子最好有示例,比如说checked(expres
来源:学生作业学帮网 编辑:学帮网 时间:2024/06/05 02:45:18
checked(expression)与unchecked(expression)的区别
C#中,关于类型转换的部分有一个问题不明白,那就是
checked(expression)
unchecked(expression)
的区别,适用的情况,最好有小程序例子
最好有示例,比如说
checked(expression)
unchecked(expression)
分别使用,如果有溢出时,得到的结果是什么,如何使用等等.
short a = 32767;
short b = 32767;
short c = (short)(a + b);
Console.WriteLine(c);
结果c是-2,显然不对,关键是程序运行没提示错误,很可能处理结果bug出现.
try
{
short a = 32767;
short b = 32767;
short c = checked((short)(a + b));
Console.WriteLine(c);
}
catch (OverflowException e)
{
Console.WriteLine(e.Message);
}
用checked检查错误.
checked(expression)与unchecked(expression)的区别C#中,关于类型转换的部分有一个问题不明白,那就是checked(expression)unchecked(expression)的区别,适用的情况,最好有小程序例子最好有示例,比如说checked(expres
checked
expression.
英语 phrase与expression的区别
not checked
checked是什么
托福checked
checked leehom的checked out
expression是什么意思?
missing expression
expression是什么意思?
checked=checked指的是什么意思?
checked bags 的 checked 是形容词吗?
checked luggage是什么意思
who checked you out
checked什么意思
checked怎么用
机票CHECKED IN代表?