C# Mastery Hub
Home
Challenges
Discussion
Lessons
Core Topics
C# Fundamentals
Console Applications
Classes & OOP
Windows Forms
ASP.NET Core
SQL Server
VS & SQL Connection
RDLC Reports
.NET MAUI
Getting Started
Getting Started
Website Development
SEO Guide
Security
Project Workflow
Extra Topics
Cloud & Deployment
AWS Cloud
Deployment
About
Contact
Test Your Knowledge
C# Fundamentals Quiz
Answer all questions to test your understanding
1
When was C# first released?
1998
2000
2002
2004
2
Who designed the C# programming language?
Bill Gates
Anders Hejlsberg
James Gosling
Bjarne Stroustrup
3
Which of the following is NOT a valid use case for C#?
Desktop applications
Web applications
Mobile applications
Hardware drivers
4
What type of programming language is C#?
Procedural only
Object-oriented
Functional only
Assembly language
5
What is the entry point of a C# program?
Start()
Main()
Run()
Begin()
6
Which IDE is recommended for C# development?
Visual Studio Code
Visual Studio
IntelliJ IDEA
Eclipse
7
Which command checks if .NET SDK is installed?
dotnet --version
dotnet check
net --version
dotnet --install
8
What is the free edition of Visual Studio called?
Visual Studio Free
Visual Studio Community
Visual Studio Express
Visual Studio Basic
9
Which tool is used for version control in C# projects?
SVN
Git
Mercurial
All of the above
10
Which command creates a new console application?
dotnet create console
dotnet new console
dotnet start console
dotnet init console
11
Which data type is used for whole numbers in C#?
double
decimal
int
float
12
What is the range of the int data type in C#?
-128 to 127
-32,768 to 32,767
-2,147,483,648 to 2,147,483,647
0 to 4,294,967,295
13
Which data type is best for precise decimal calculations like money?
double
float
decimal
int
14
What does the 'var' keyword do in C#?
Creates a variable without a type
Implicitly types a variable based on the value
Makes a variable constant
Creates a global variable
15
What is a nullable type in C#?
A type that can be null
A type that cannot be null
A type that is always optional
A type with a default value of null
16
What does the % operator do in C#?
Division
Multiplication
Modulus (remainder)
Percentage
17
What is the result of 10 / 3 in C# (integer division)?
3.333
3
4
3.33
18
Which operator is used for logical AND in C#?
&
&&
and
AND
19
What is the difference between ++x and x++?
No difference
++x increments before use, x++ increments after use
x++ increments before use, ++x increments after use
They produce different results only with strings
20
Which operator is used for string concatenation?
+
&
.
,
21
What does the if statement do in C#?
Executes code based on a condition
Repeats code multiple times
Defines a new variable
Creates a new class
22
Which statement is best for multiple condition checks?
if-else if
switch
while
for
23
What does the break keyword do in a switch statement?
Continues to next case
Exits the switch block
Restarts the switch
Skips the current iteration
24
What is the ternary operator syntax in C#?
condition ? true_value : false_value
condition : true_value ? false_value
true_value ? condition : false_value
condition ? false_value : true_value
25
What does the default case do in a switch statement?
Handles all unmatched values
Handles only the first value
Exits the switch
Throws an exception
26
Which loop is best when you know how many times to iterate?
while
do-while
for
foreach
27
Which loop always executes at least once?
for
while
do-while
foreach
28
What does the continue statement do in a loop?
Exits the loop entirely
Skips the current iteration
Restarts the loop
Throws an exception
29
Which loop is specifically designed for collections?
for
while
do-while
foreach
30
What does the break statement do in a loop?
Skips the current iteration
Exits the loop entirely
Restarts the loop
Continues to the next iteration
31
What is the index of the first element in an array?
0
1
-1
Depends on the array
32
Which collection type stores key-value pairs?
List<T>
Array
Dictionary<TKey, TValue>
Queue<T>
33
What is the difference between Array and List<T>?
Arrays are dynamic, Lists are fixed
Arrays are fixed, Lists are dynamic
There is no difference
Arrays can only store strings
34
Which collection ensures all items are unique?
List<T>
HashSet<T>
Array
Dictionary<TKey, TValue>
35
What is a multidimensional array?
An array with more than one dimension
An array of arrays
A collection of arrays
A list of arrays
36
Are strings mutable or immutable in C#?
Mutable
Immutable
Both
Depends on the version
37
Which class should you use for heavy string manipulation?
String
StringBuilder
StringBuffer
StringWriter
38
What is string interpolation?
Concatenating strings with +
Embedding expressions inside strings using $
Splitting strings into parts
Converting strings to numbers
39
Which method splits a string into an array of substrings?
Split()
Substring()
IndexOf()
Replace()
40
What does the Trim() method do to a string?
Removes all spaces
Removes leading and trailing spaces
Removes only leading spaces
Removes only trailing spaces
41
What is exception handling in C#?
Ignoring errors in code
Handling runtime errors gracefully
Preventing all errors
Logging only errors
42
What is the correct order of catch blocks?
Most specific to most general
Most general to most specific
Order doesn't matter
Only one catch block is allowed
43
What is the purpose of the finally block?
To catch exceptions
To always execute code regardless of exceptions
To throw exceptions
To log errors
44
Which keyword is used to throw a custom exception?
throw
throws
raise
error
45
What does the using statement do?
Imports a namespace
Automatically disposes objects
Creates a new object
Defines a scope
46
What is a method in C#?
A block of code that performs a specific task
A variable that stores data
A type of class
A property that validates data
47
What is method overloading?
Multiple methods with the same name but different parameters
Methods with different names
Methods in different classes
Methods that return different types
48
What does the 'params' keyword do?
Makes a parameter optional
Allows a method to accept a variable number of arguments
Makes a parameter read-only
Passes parameters by reference
49
What is the difference between ref and out parameters?
ref requires initialization, out doesn't
out requires initialization, ref doesn't
They are the same
ref is for value types only
50
What is a static method?
A method that belongs to the class, not an instance
A method that belongs to an instance
A method that never changes
A method that cannot be called
51
How do you declare a nullable int in C#?
int? myInt
int myInt?
nullable int myInt
int myInt = null
52
What does the ?? operator do?
Checks if a value is null
Returns the left operand if not null, otherwise the right operand
Checks for equality
Throws an exception if null
53
What does the 'is' keyword do in pattern matching?
Checks type compatibility
Casts an object
Creates a new object
Deletes an object
54
What is pattern matching in C#?
A way to match strings
A way to test values against patterns
A way to create patterns
A way to format strings
55
What does the ??= operator do?
Assigns a value if the variable is null
Checks for null
Throws an exception
Creates a new variable
56
What does LINQ stand for?
Language Integrated Query
Language Interrogation Query
Linear Integrated Query
Language Integrated Question
57
Which LINQ method filters a collection?
Select
Where
OrderBy
GroupBy
58
Which LINQ method transforms a collection?
Where
Select
OrderBy
GroupBy
59
Which LINQ method calculates the sum of a numeric property?
Average
Sum
Count
Max
60
Which LINQ method checks if any element meets a condition?
All
Any
Contains
Exists
61
What is a delegate in C#?
A type that holds a reference to a method
A type of class
A type of variable
A type of collection
62
What is the difference between Func and Action in C#?
Func returns a value, Action doesn't
Action returns a value, Func doesn't
They are the same
Func is for strings only
63
What is an event in C#?
A way to raise notifications
A type of delegate
A type of class
A type of variable
64
What does the async keyword do?
Makes a method synchronous
Marks a method as asynchronous
Makes a method faster
Makes a method return void
65
What does the await keyword do?
Blocks the thread
Suspends execution until the awaited task completes
Creates a new thread
Cancels the operation
Submit Quiz