声明VB.NET中的一个十六进制常数 [英] Declaring a hex constant in VB.NET

查看:1371
本文介绍了声明VB.NET中的一个十六进制常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何转换下面的C#十六进制到 VB.NET 十六进制?



 私人常量UInt32的TEMP = 0xE6359A60; 



我试过以下,但它不工作。

 公共常量临时作为System.UInt32 = 0xE6359A60 


解决方案

C#使用 0X VB.NET 使用&放大器; H 并指定十六进制数前缀
试试这个

 公共常量温度为整数=&放大器; HE6359A60 

子主要

端子

和它可能是为UINT也:

 公共常量临时作为UInt32的=安培; HE6359A60UI 

子主要

端子

检查MSDN的类型的字符(Visual Basic)中定义的十六进制和八进制文字文档:




编译器通常串讲文字是在$一个整数b $ b十进制(基数为10)数字系统。您可以强制文字以
的整数十六进制(基数为16)&放大器; H前缀,然后可以将其强制
是< STRONG>八进制(基数8)与&放大器;Ø前缀。 。后面的
前缀数字必须是适当的数字系统




参考文献:




How can I convert the following C# hexadecimal into a VB.NET hexadecimal?

private const UInt32 temp = 0xE6359A60;

I tried the following, but it doesn't work.

Public Const temp As System.UInt32 = 0xE6359A60

解决方案

C# uses 0x and VB.NET uses &H as the prefix to specify hexadecimal numbers. try this.

Public Const temp As Integer = &HE6359A60

Sub Main

End Sub

And it could be as Uint also:

Public Const temp As UInt32 = &HE6359A60UI

Sub Main

End Sub

Check MSDN's Type Characters (Visual Basic) documentation for defining hexadecimal and octal literals:

The compiler normally construes an integer literal to be in the decimal (base 10) number system. You can force an integer literal to be hexadecimal (base 16) with the &H prefix, and you can force it to be octal (base 8) with the &O prefix. The digits that follow the prefix must be appropriate for the number system.

References:

这篇关于声明VB.NET中的一个十六进制常数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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