Replies: 6 comments 15 replies
-
Historically and currently, bytes are much more frequently used as unsigned, therefore they chose to make WRT "why not Int8 and UInt8", it does look like it's inconsistent with other types, but for naming purposes, they made that choice back in the day - difficult to say now - but I'm willing to bet that they did it to be consistent with the languages, because originally the first versions of both the framework and C# were designed together. Byte was just decided to be a "special" integer type - and that "specialness" was consistently applied across the languages and the framework. PS. Don't quote me on any of this - I wasn't part of decision making about any of this. |
Beta Was this translation helpful? Give feedback.
-
This is more a runtime question as C# has it's own names for those types, none of which include the size of the type. As mentioned by @TahirAhmadov I believe the signed-ness aspect of the name was to indicate which was expected to be more commonly used and supported, and this is reflected in the Common Language Specification where the only unsigned type considered compliant is |
Beta Was this translation helpful? Give feedback.
-
imo |
Beta Was this translation helpful? Give feedback.
-
if feel the struct name is be Int8 and UInt8, when working in max memory optimization projects, it is easy to understand, for byte and sbyte struct naming wand to keep that in mind it is how much bytes taking in that memory. normal users using keyword with differ naming and max memory optimization mind set users use struct with proper memory size naming in struct. |
Beta Was this translation helpful? Give feedback.
-
Microsoft adopted <stdint.h> only in VS 2010. Even gcc added it only in 2001. Back around the turn of the millennium, when C# was being designed, there was no real point of reference for language designers to rationalize the switch to [u]intN or {u|i}N naming schema away from C's unsigned char/short/int/long. |
Beta Was this translation helpful? Give feedback.
-
Why |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
sbyte -128 to 127 Signed 8-bit integer System.SByte
byte 0 to 255 Unsigned 8-bit integer System.Byte
short -32,768 to 32,767 Signed 16-bit integer System.Int16
ushort 0 to 65,535 Unsigned 16-bit integer System.UInt16
int -2,147,483,648 to 2,147,483,647 Signed 32-bit integer System.Int32
uint 0 to 4,294,967,295 Unsigned 32-bit integer System.UInt32
long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer System.Int64
ulong 0 to 18,446,744,073,709,551,615 Unsigned 64-bit integer System.UInt64
All Integral Data Type Struct have proper naming like Int16, UInt16, Int32, UInt32.
non "U" char - to +
with "U" 0 to +
and Size also in that Struct name Int16, Int32, Int64 everting good.
but why Sbyte and byte naming was different, have any reason for this ?
why not Int8 and UInt8 ?
Beta Was this translation helpful? Give feedback.
All reactions