首页 > 学院 > 开发设计 > 正文

函数参数中“x++与x+1”造成的运算无效测试

2019-11-17 02:28:30
字体:
来源:转载
供稿:网友

函数参数中“x++与x+1”造成的运算无效测试

可能以前书上都有说过,当时没在意

只有在实际项目中才会遇到因这个问题导致的Bug

var tmp1 = 10;var tmp2 = Math.Max(tmp1++, 10);Console.WriteLine(tmp2);Console.Read();//PRint 10

var tmp1 = 10;var tmp2 = Math.Max(tmp1+1, 10);Console.WriteLine(tmp2);Console.Read();//print 11


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表