.NET

C# Basics

Variables & constants, primitive types, control flow, classes, structs, interfaces, exceptions

25 câu hỏi phỏng vấn·
Junior
1

What is a variable in C#?

Câu trả lời

A variable is a named storage location in memory that holds a value which can be modified during program execution. Each variable has a type that determines what values it can contain and what operations are allowed. Declaring a variable with an explicit type allows the compiler to verify code consistency and optimize memory usage.

2

What is the difference between a variable and a constant in C#?

Câu trả lời

A variable can have its value changed after initialization, whereas a constant receives a value at compilation that remains fixed throughout the program's lifetime. Constants are declared with the const keyword and must be initialized with a compile-time known value. Using constants for immutable values improves readability and enables compiler optimizations.

3

What is the appropriate type to store a simple integer in C#?

Câu trả lời

The int type is the most commonly used integer type in C# for storing whole numbers. It occupies 32 bits in memory and can hold values ranging from approximately -2 billion to +2 billion. For most use cases involving counters, indices, or quantities, int provides a good balance between value range and performance.

4

What type should be used to store a true/false value in C#?

5

What is the correct syntax to declare a constant in C#?

+22 câu hỏi phỏng vấn

Nắm vững .NET cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí