问题描述
如何将以下 C# 十六进制转换为 VB.NET 十六进制?
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# 使用 0x
和 VB.NET 使用 &H
作为前缀来指定十六进制数.试试这个.
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
它也可以是 Uint:
And it could be as Uint also:
Public Const temp As UInt32 = &HE6359A60UI
Sub Main
End Sub
查看 MSDN 的 Type Characters (Visual Basic) 文档以定义十六进制和八进制文字:
Check MSDN's Type Characters (Visual Basic) documentation for defining hexadecimal and octal literals:
编译器通常将整数文字解释为十进制(以 10 为底)数字系统.您可以强制整数文字十六进制(以 16 为基数) 加上 &H 前缀,你可以强制它八进制(以 8 为基数),带有 &O 前缀.后面的数字前缀必须适合数字系统.
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.
参考资料:
- 十六进制数(不是 ASCII 十六进制值)到 VB.NET 中的字符串(堆栈溢出)
- &H57 代表什么以及如何将其翻译为 C#?(堆栈溢出)
- 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)
这篇关于在 VB.NET 中声明一个十六进制常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!