C# 在 VB.NET 中声明一个十六进制常量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10240587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Declaring a hex constant in VB.NET
提问by Ali
采纳答案by Niranjan Singh
C# uses 0xand VB.NETuses &Has the prefix to specify hexadecimal numbers.try this.
C# 使用0x和VB.NET使用&H作为前缀来指定十六进制数字。尝试这个。
Public Const temp As Integer = &HE6359A60
Sub Main
End Sub
And it could be as Uint also:
它也可以是 Uint:
Public Const temp As UInt32 = &HE6359A60UI
Sub Main
End Sub
Check MSDN's Type Characters (Visual Basic)documentation for defining hexadecimal and octal literals:
检查 MSDN 的类型字符 (Visual Basic)文档以定义十六进制和八进制文字:
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.
编译器通常将整数文字解释为十进制(基数为 10)的数字系统。您可以使用&H 前缀强制整数文字为十六进制(以16 为底),也可以使用&O 前缀将其强制为八进制(以 8为底)。前缀后面的数字必须适用于数字系统。
References:
参考:
- Hex number (not ASCII hex value) to string in VB.NET(Stack Overflow)
- What does &H57 represent and how can I translate it for C#?(Stack Overflow)
回答by Alex
Public Const temp As Integer = &H6359A60
Prefix it with &H
前缀为 &H

