将整数转换为布尔值? [英] Cast Integer as Boolean?

查看:119
本文介绍了将整数转换为布尔值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,


如何在VB.NET中将System.Int32转换为布尔值?


我知道我用过在VB6中使用Cbool(myInt),但我似乎没有找到

.NET等价物。


-Joel

Hello All,

How can I cast a System.Int32 as a boolean in VB.NET?

I know I used to used Cbool(myInt) in VB6, but I cxan''t seem to find the
.NET equivalent.

-Joel

推荐答案

Dim temp As Int32 = 1

Dim temp2 As Boolean

temp2 = System.Convert.ToBoolean( temp)


" Joel Whitehouse" <乔************ @ gmail.com>在消息中写道

新闻:O%**************** @ TK2MSFTNGP12.phx.gbl ...
Dim temp As Int32 = 1
Dim temp2 As Boolean
temp2 = System.Convert.ToBoolean(temp)

"Joel Whitehouse" <jo************@gmail.com> wrote in message
news:O%****************@TK2MSFTNGP12.phx.gbl...
Hello All ,

如何在VB.NET中将System.Int32强制转换为布尔值?

我知道我曾经在VB6中使用过Cbool(myInt),但我是cxan'似乎找不到
.NET等价物。

-Joel
Hello All,

How can I cast a System.Int32 as a boolean in VB.NET?

I know I used to used Cbool(myInt) in VB6, but I cxan''t seem to find the
.NET equivalent.

-Joel






David A. Osborn写道:
David A. Osborn wrote:
Dim temp As Int32 = 1
Dim temp2 As Boolean
temp2 = System.Convert.ToBoolean(temp)
Dim temp As Int32 = 1
Dim temp2 As Boolean
temp2 = System.Convert.ToBoolean(temp)




非常感谢您的帮助!祝你有美好的一天!


-Joel



Thanks so much for your help! Have a great day!

-Joel


Joel,


Don'在VBNet中混合单个System命名空间与.Net

框架有更多的东西。

例如Microsoft.VisualBasic命名空间

正确的(最优化的)VBNet表示法是:


Dim IsFalse As Boolean = CBool​​(New System.Int32)


我希望这会有所帮助,


Cor
Joel,

Don''t mixup in VBNet the single System namespace with .Net
The framework has more things than that.
By instance the Microsoft.VisualBasic namespace

The correct (most optimized) VBNet notation is:

Dim IsFalse As Boolean = CBool(New System.Int32)

I hope this helps,

Cor


这篇关于将整数转换为布尔值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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