C# Quiz for Beginners
Test and improve your basic C# programming skills with this interactive quiz — perfect for students and beginners!
Progress: 1/10
Score: 0%
What is the correct way to declare a variable of type integer in C#?
Explanation
In C#, you declare an integer variable using the 'int' keyword followed by the variable name and optional initialization.
Your Results
80%
Overall Score
Performance Breakdown
- Syntax Questions 4/5
- Variable Questions 3/3
- Loop Questions 1/2
C# Quick Reference
int x = 10;– Declares an integer variablestring name = "Alice";– Declares a string variableif (x > 5) { ... }– Basic if statementConsole.WriteLine("Hello");– Output to console
| Type | Example | Description |
|---|---|---|
int |
int age = 25; |
Whole numbers |
double |
double price = 9.99; |
Decimal numbers |
bool |
bool isActive = true; |
True/False values |
string |
string name = "John"; |
Text values |
Class: Blueprint for creating objects.
public class Person {
public string Name;
public int Age;
}
Method: A function defined inside a class.
public void Greet() {
Console.WriteLine($"Hello, my name is {Name}");
}
Object: Instance of a class.
Person person1 = new Person();
person1.Name = "Alice";