C# crash course Flashcards

1
Q

What is C#?

A

OOP, high level programming language developed by Microsoft as part of its .Net ecosystem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some advantages of C# compared to other languages?

A
  • Cross platform with .Net core
  • Strong memory management (garbage collection)
  • Seamless integration with Microsoft
  • LINQ, enables SQL-lite quieries directly in C#
  • Supports asynchronous
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are records?

A

A group of variables (unchangeable once created)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a struct?

A

Used for storing data types, (class with no methods). Exists in memory, therefore fast to access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an interface?

A

An interface defines properties and methods implementing classes must implement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a task in C#?

A

Represents an asynchronous operation that allows you to run code concurrently without blocking the main thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is async and await used for?

A

Allows you to write asynchronous code. Await is used to suspend the execution of the async method until the asynchronous tasks completes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does ‘Parallel.ForEach’ do?

A

Runs loop iterations in parallel, making it efficient for CPU-bound tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a lock in C#

A

Prevents multiple threads from accessing a code block simultaneously, only one thread can execute this block at a time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a mutex?

A

A cross-process lock that can be used for synchronization across different applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a semaphore?

A

Limits the number of threads that can access a resource concurrently

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is inheritance vs composition?

A

Inheritance one class inherits from another, composition one class contains another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an abstract class?

A

A class that can provide default implementations but cannot be instantiated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s the difference between a task and a thread?

A

Task is managed by .NET and is better for scalability. Thread is a lower-level construct that gives direct control but is resource heavy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does dependency injection work in .NET?

A

Allows you to inject dependencies at runtime using constructors or properties, promoting loose coupling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an example of polymorphism?

A

Creating an animal class with the method makeNoise and a child class like dog overriding it

17
Q

What are implicit typed variables ?

A

Variables types that are determined by the compiler