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 inconsistent if you use var for local variables.
I am wondering if there is any way to declare a byte variable in
Share
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:
If you want to use
var, you can always cast the byte as invar y = (byte) 5Although not really related, in C#7, a new binary prefix was introduced
0b, which states the number is in binary format. Still there is no suffix to make it a byte though, example: