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 中声明一个十六进制常量
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- WPF 模态进度窗口 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
