Language specifics Flashcards

1
Q

Explain the difference between Task and Thread in .NET

A

Thread class is a .NET representation of operation system threads, it allows low-level management of threads, where Task is an abstraction for an operation that can be run asynchronously or in parallel. Task execution does not always utilizes threads (like when it represents IO operation) and does not map to thread 1 to 1 - it uses thread pooling to reuse threads instead of creating new ones.

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

Explain when to use Finalize vs Dispose?

A

Finalize is a method that Garbage Collector executes before terminating an object so we don’t have a control over exact moment when it executes, so we can’t rely on finalization to free some unmanaged resources. Dispose, however, even while it has language support of using block, is not guaranteed to be executed, because it is supposed to be executed manually.
It’s better to use disposable most of the time and protect yourself with compiler and IDE warnings if disposable object is not disposed.

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

What’s the difference between RyuJIT and Roslyn?

A

Roslyn compiler compiles C# code into Intermediate Language code, when RyuJIT is just-in-time compiler that compiles IL code into native code on demand in runtime.

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

What is Boxing and Unboxing?

A
Boxing is a conversion of a value type instance into reference of object class which is made to unify type system and let developers pass values to methods that require object.
Unboxing is a reverse conversion to original value type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly