.NET Backend Interview: 26 Questions — In-Depth Analysis of Concurrency, Caching, Databases, and Industrial Communication
This article provides an in-depth analysis of several core technical aspects within the C# and .NET ecosystem. First, it clarifies the fundamental differences between events and delegates, emphasizing the strict restrictions on external assignment and triggering for events. Second, it elaborates on the .NET garbage collection generational model, Large Object Heap (LOH) characteristics, and optimization strategies, recommending the use of object pools and `Span` to reduce GC pressure. In terms of architectural choices, it compares the differences between time-series databases and relational databases in storage, writing, and querying, noting that they are typically used together; it also analyzes the advantages and limitations of gRPC based on HTTP/2 and Protobuf, as well as the solution for implementing connection count limits in clustered environments using SignalR with Redis. Regarding the challenge of exporting million-row datasets to Excel, it proposes solutions such as asynchronous tasks, streaming reads, and streaming write libraries like MiniExcel to avoid out-of-memory errors. Additionally, the article distinguishes the practical differences between baud rate and bit rate in serial communication, outlines C# thread synchronization mechanisms, and points out that `SemaphoreSlim` should be used instead of `lock` in asynchronous scenarios. Finally, by comparing the underlying structures and time complexities of `List` and `Dictionary`, it emphasizes the importance of leveraging dictionaries to optimize lookup performance in large-scale data scenarios, and provides interview tips, suggesting the use of real project data to demonstrate technical depth.