文字后缀为.NET字节? [英] Literal suffix for byte in .NET?

查看:101
本文介绍了文字后缀为.NET字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有什么办法像浮点或双精度一小段路来声明一个字节变量?我的意思是像 5D 1006米和。当然,我可以写字节x = 5 ,但是这是一个有点微不足道,如果你使用 VAR 局部变量。

I am wondering if there is any way to declare a byte variable in a short way like floats or doubles? I mean like 5f and 5d. Sure I could write byte x = 5, but that's a bit inconsequential if you use var for local variables.

推荐答案

有一个字面后缀上的字节为MSDN 参考以及在 C#4.0语言规范。在C#中只包含文字后缀是整数,实数如下:

There is no mention of a literal suffix on the MSDN reference for Byte as well as in the C# 4.0 Language Specification. The only literal suffixes in C# are for integer and real numbers as follows:

u = uint
l = long
ul = ulong
f = float
m = decimal
d = double

如果你想使用 VAR ,你总是可以投的字节为 VAR Y =(字节)5

If you want to use var, you can always cast the byte as in var y = (byte) 5

这篇关于文字后缀为.NET字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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