Unsigned vs signed storage in C#.NET — which of the following types does not store a sign bit?

Difficulty: Easy

Correct Answer: Byte

Explanation:


Introduction / Context:
Signedness determines whether a numeric type can represent negative values. In C#, some aliases map to signed types and some to unsigned types.



Given Data / Assumptions:

  • “Integer” here refers to a 32-bit signed Int32 (VB alias), while C# uses the alias int.
  • Byte in C# is unsigned (0 to 255). sbyte is the signed 8-bit counterpart but is not listed.


Concept / Approach:
Short (Int16), Integer/Int32, and Long (Int64) are signed types; Single is a floating-point type with sign. Only Byte (System.Byte) is unsigned among the options, and thus does not store a sign bit.



Step-by-Step Solution:

Map each alias to its CLR type and signedness.Confirm that only Byte lacks a sign.


Verification / Alternative check:
Check sizeof(byte) == 1 and ranges: 0..255, versus short (−32768..32767), int (−2,147,483,648..2,147,483,647), long (−9,22e18..).



Why Other Options Are Wrong:
They all represent signed storages or floating-point with sign.



Common Pitfalls:
Confusing C# Byte (unsigned) with sbyte (signed) or mixing VB and C# naming.



Final Answer:
Byte

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion