C# - Datatypes Questions and Answers
The C# Datatypes questions with answers section is designed for programmers preparing for interviews and coding tests. These programming questions and answers focus on understanding how data types are defined, declared, and managed in C#. Top recruiters like TCS, Wipro, and Accenture often include datatype-based MCQs to assess logical and memory management skills. By exploring C# programming interview questions with answers, candidates can strengthen their foundational knowledge of variables, value types, reference types, and data conversions. This topic is ideal for learners seeking to master .NET concepts for competitive programming and job interviews.
Understand data types available in C programming. Also check C structures and C dynamic memory allocation
C# - Datatypes
21. Which of the following is a reference data type?
- int
- double
- char
- string Explanation: String is a reference type in C#.
22. What is the size of int data type in C#?
- 2 bytes
- 4 bytes Explanation: An int occupies 4 bytes in C#.
- 8 bytes
- Depends on system
23. Which data type can store decimal values with high precision?
- float
- double
- decimal Explanation: Decimal provides higher precision, mainly used in financial calculations.
- long
24. Which keyword is used to define a user-defined data type in C#?
- struct
- enum
- class
- All of the above Explanation: Struct, enum, and class all define user-defined data types.
25. What is the size of char data type in C#?
- 1 byte
- 2 bytes Explanation: Char stores Unicode characters and occupies 2 bytes.
- 4 bytes
- 8 bytes
26. Which data type should be used to store a large whole number?
- int
- short
- long Explanation: Long is used for storing large integer values.
- byte
27. Which of the following is NOT a built-in data type in C#?
- float
- string
- object
- variant Explanation: Variant is not a data type in C#.
28. Which data type is the base type of all data types in C#?
- string
- object Explanation: Object is the base class for all types in C#.
- dynamic
- var
29. Which keyword allows implicit type inference in C#?
- dynamic
- object
- var Explanation: var lets the compiler infer the type at compile time.
- auto
30. Which data type stores a single Unicode character?
- string
- char Explanation: Char represents a single Unicode character.
- byte
- bool