整数溢出 - 转换C#来VB.Net代码 [英] Integer Overflow - Converting C# to VB.Net code

查看:170
本文介绍了整数溢出 - 转换C#来VB.Net代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

得到了与从C#到VB.Net代码转换问题

Got a problem with a code conversion from C# to VB.Net.

var x = 5783615;
var y = 56811584;
var t = x * y;



x,y和t均为整数。在C#'T'将是-15536​​49728。
在VB.Net,我会得到一个整数溢出异常。

x, y and t are integers. In c# 't' will be -1553649728. In VB.Net, I will get an integer overflow exception.

不知道如何解决它?

推荐答案

C#,默认情况下,不检查溢出,但VB做(默认情况下)。

C#, by default, doesn't check for overflows, but VB does (by default).

您可以设置你的VB项目不检查在编译选项卡的高级编译选项整数溢出。这将导致特定项目要停止加发生OverflowException 在这样的情况下。

You can setup your VB Project to not check for integer overflows in the Advanced Compile Options in the Compile tab. This will cause that specific project to stop raising OverflowException in cases like this.

这篇关于整数溢出 - 转换C#来VB.Net代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆