Integral types in C#.NET — which of the following is an 8-byte signed integer type?

Difficulty: Easy

Correct Answer: Long

Explanation:


Introduction / Context:
C#.NET defines several integral types with specific sizes and signedness. Correctly identifying their sizes is essential for interoperability and memory considerations.



Given Data / Assumptions:

  • We use C# type aliases: long = System.Int64, short = System.Int16, byte = System.Byte (unsigned), char = UTF-16 code unit.
  • “Integer” is often a VB alias for Int32; in C# the alias is int.


Concept / Approach:
Among the listed types, only long corresponds to a signed 64-bit (8-byte) integer in C#. Short is 16-bit, Byte is 8-bit unsigned, Char is 16-bit Unicode scalar storage, and “Integer” typically refers to a 32-bit signed integer (Int32) in VB.



Step-by-Step Solution:

Map each name to its CLR size.long → 8 bytes; short → 2 bytes; byte → 1 byte (unsigned); char → 2 bytes; VB Integer → 4 bytes.Therefore, the 8-byte integer is long.


Verification / Alternative check:
Use sizeof(long) == 8 in an unsafe block, or check official type mappings.



Why Other Options Are Wrong:
They denote types that do not have 8-byte signed integer semantics in C#.



Common Pitfalls:
Confusing C# and VB aliases, especially “Integer” vs. C#'s “int”.



Final Answer:
Long

Discussion & Comments

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