.NET

Reactive Programming

Reactive Extensions (Rx), IObservable, operators, schedulers, backpressure (optional, less common in modern web APIs)

24 คำถามสัมภาษณ์·
Senior
1

What is the IObservable<T> interface in Reactive Extensions (Rx.NET)?

คำตอบ

IObservable<T> is the fundamental interface in Rx.NET that represents a push-based data source. It exposes a Subscribe method allowing observers to subscribe to receive asynchronous notifications. It's the reactive counterpart to IEnumerable<T>: while IEnumerable pulls data synchronously, IObservable pushes data asynchronously to subscribers.

2

What are the three methods of the IObserver<T> interface in Rx.NET?

คำตอบ

IObserver<T> defines three methods: OnNext(T value) to receive each element of the sequence, OnError(Exception error) to handle errors and signal the end of the sequence in case of failure, and OnCompleted() to indicate that the sequence completed successfully. These three methods form the observer contract which guarantees that after OnError or OnCompleted, no further OnNext will be called.

3

What is the main difference between IEnumerable<T> and IObservable<T>?

คำตอบ

IEnumerable<T> is a pull model where the consumer requests data synchronously with GetEnumerator() and MoveNext(). IObservable<T> is a push model where the source pushes data asynchronously to subscribers via Subscribe(). IEnumerable blocks the calling thread during iteration, while IObservable enables non-blocking operations and composition of asynchronous events with LINQ operators.

4

What is the role of the Select operator in Rx.NET?

5

How does the Where operator work in Rx.NET?

+21 คำถามสัมภาษณ์

เชี่ยวชาญ .NET สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี