0
0
C Sharp (C#)programming~5 mins

Integer types and their ranges in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the range of the int type in C#?
The int type in C# is a 32-bit signed integer. It ranges from -2,147,483,648 to 2,147,483,647.
Click to reveal answer
beginner
What is the difference between int and uint in C#?
int is a signed 32-bit integer (can hold negative and positive numbers). uint is an unsigned 32-bit integer (only positive numbers and zero). uint ranges from 0 to 4,294,967,295.
Click to reveal answer
intermediate
What is the size and range of the long type in C#?
long is a 64-bit signed integer. It ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
Click to reveal answer
beginner
Which integer type would you use to store only positive numbers up to about 65,000?
You would use ushort, which is an unsigned 16-bit integer ranging from 0 to 65,535.
Click to reveal answer
intermediate
What happens if you try to store a number outside the range of an integer type in C#?
If you store a number outside the range, it causes an overflow. By default, this can wrap around silently or throw an exception if checked context is used.
Click to reveal answer
What is the range of the byte type in C#?
A0 to 65,535
B-128 to 127
C-32,768 to 32,767
D0 to 255
Which type is a 16-bit signed integer in C#?
Ashort
Bushort
Cint
Dlong
What is the size of the uint type in C#?
A8 bits
B16 bits
C32 bits
D64 bits
Which integer type can store the largest positive number?
Along
Bint
Cushort
Dbyte
What keyword can you use to detect overflow errors in C#?
Aoverflow
Bchecked
Cunchecked
Dsafe
Explain the difference between signed and unsigned integer types in C# and give examples.
Think about whether the number can be negative or not.
You got /3 concepts.
    List the common integer types in C# and their size in bits.
    Remember the smallest to largest sizes.
    You got /5 concepts.