“字节”的后缀是什么(类型字符)? VB.NET中的数字常量? [英] What's the suffix (type character) for "Byte" numeric constants in VB.NET?

查看:93
本文介绍了“字节”的后缀是什么(类型字符)? VB.NET中的数字常量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是出于好奇:

我知道我可以告诉编译器是否希望将值解释为某些数字类型,例如作为整数(32位带符号),通过这种方式在常量值后面附加一个 I(类型字符):

I know I can tell the compiler if I want a value to be interpreted as a certain numeric type, e.g. as Integer (32 bit signed), this way appending an "I" (type character) to the constant value:

Private Function GetTheAnswerAsInteger() As Integer

   Return 42I

End Function

还有 S(缩写), D(十进制)等。

There's also "S" for Short, "D" for Decimal, etc.

但是后缀为Byte 是什么?提示:它不是显而易见的一个 B ...

But what is the suffix for Byte? Hint: it's not the obvious one "B"...

推荐答案

没有一个。如果需要区分常量的整数和字节(例如,调用适当的重载),则需要进行强制转换。

There isn't one. If you need to distinguish between an integer and a byte (e.g. to call an appropriate overload) for a constant, you need to cast.

(C#中也是如此,顺便说一句。)

(The same is true in C#, by the way.)

MSDN提供确认:


字节没有文字类型字符或
标识符类型字符。

Byte has no literal type character or identifier type character.

还有一个类型字符和文字后缀的列表

这篇关于“字节”的后缀是什么(类型字符)? VB.NET中的数字常量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆