Declaring a hex constant in VB.NET(在 VB.NET 中声明一个十六进制常量)
问题描述
如何将以下 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 中声明一个十六进制常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 VB.NET 中声明一个十六进制常量
基础教程推荐
- 获取C#保存对话框的文件路径 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 如果条件可以为空 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 将数据集转换为列表 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
