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 中声明一个十六进制常量
基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
