Recent .NET Interview Questions Sharing and Summary

Recent .NET Interview Questions Sharing and Summary

The following content is not all of the .NET interview, but some things that I think might be overlooked.

Last updated 3/1/2023 11:02 PM
少年知有
11 min read
Category
.NET
Tags
.NET C#

The following content is not the entirety of NET interviews, but rather some points that I think might be overlooked.

1. Interview Summary

Avoid pitfall: Shenzhen Longgang Li Lang YH Shares may renege on job offers.

Because my offer was revoked, I had to look for a job again. From the 8th to the 12th (11 companies), the overall interview difficulty was not high, but many companies were just going through the motions and didn't really need people. Some even sent me home after a few words to wait for notification. It's worth noting that before the interview, you should understand what the company does and roughly what their business is. Since resume approval usually means the technology matches or a project is similar, this can help you avoid being unable to answer during the second round. Also, be sincere in interviews within the same city, because HR and management might know each other.

2. Interview Content Summary:

Backend technical points: Object-oriented programming, common algorithms and implementations, common design patterns, C# basics, .NET Core (middleware, differences from .NET, IOC/DI, AOP, domestic frameworks (Furion)), EF Core and ORM related, multithreading, performance optimization, caching (Redis, MongoDB), MQ, microservices, distributed (less), Docker (less), CI/CD (less), Linux (less), database sharding (less).

Database technical points: SQL syntax, indexes, query optimization, stored procedures, differences between mainstream databases (SQL Server, MySQL, PostgreSQL (less)), deadlocks, transactions, functions, B+ trees, red-black trees, B-trees (this part is rare).

Frontend technical points: Vue, jQuery, uniapp.

Business-related: 1. Do you communicate directly with clients or on-site personnel to gather requirements, and how do you do it? 2. Explain the functionality and scenarios of a project, whether you encountered any problems, and how they were resolved.

Interview questions (the parts I remember):

  1. Explain your understanding of object-oriented programming and its characteristics.

Reference answer: https://blog.csdn.net/weixin_51201930/article/details/122652397

Answer: Object-oriented refers to abstracting things in the real world into objects, each with corresponding methods and properties. The three main features of object-oriented programming are inheritance, encapsulation, and polymorphism.

  1. What algorithms do you usually use at work?

Reference answers: https://blog.csdn.net/dreame_life/article/details/104342490 https://www.runoob.com/w3cnote/ten-sorting-algorithm.html

Answer: Recursion, bubble sort, binary search. (I think this question is actually asking about data structures; you can refer to this: https://blog.csdn.net/heyuchang666/article/details/49891635)

  1. What common design patterns do you know? Which ones have you used at work?

Reference answer: https://www.cnblogs.com/abcdwxc/archive/2007/10/30/942834.html

Answer: Adapter, Decorator, Abstract Factory.

  1. What are the value types and reference types in C#? What is the difference?

Reference: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types Answer: Value types include integer types, floating-point types, boolean, struct, enum, tuple, and char. Reference types include class, interface, delegate, record, dynamic, object, and string.

A variable of a value type contains an instance of the type. This is different from a variable of a reference type, which contains a reference to an instance of the type.

Value types implicitly derive from System.ValueType.

  1. What are the collection types in C#? What is the difference between them?

Reference: https://learn.microsoft.com/en-us/dotnet/standard/collections/commonly-used-collection-types

Answer: The commonly used ones are: ArrayList, List, Queue, Hashtable, Dictionary. The differences are in thread safety and application scenarios. For example, List is thread-safe for reading while ArrayList is not. List can be used for sorting and searching with generics. Dictionary is used for key-value pair collections. Queue represents a first-in-first-out collection of objects. Use a queue when you need first-in-first-out access to items. Each item in a Hashtable has a key/value pair. You can access items in the collection directly using the hash key.

  1. What are the differences between char, string, and StringBuilder?

Reference: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/ https://blog.csdn.net/qq_44034384/article/details/106739003

Answer: char is used to store a single character. string is a sequential read-only collection of char objects. Each modification to a string creates a new string object. The StringBuilder class is different: each operation modifies the object itself instead of generating a new object. Its memory space expands as content increases. When performing a large number of modification operations, it does not create many anonymous objects, thus avoiding performance impact.

  1. What are the differences between .NET Framework, .NET Standard, .NET Core, and .NET 5/6/7?

Answer: .NET Framework and .NET Core can both be used to build various types of applications. .NET Framework can only run on Windows. .NET Core is a free, open-source, managed framework that works on Windows, Linux, and macOS operating systems. .NET 5/6/7 are stable versions of .NET Core. .NET Standard is a specification, like a mapping table, that corresponds certain assemblies of .NET Framework to .NET Core.

  1. Talk about your understanding of middleware and the pipeline in .NET Core.

Reference: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-6.0

Answer: The complete request processing of an application is called the pipeline. Middleware is a component assembled into an application pipeline to handle requests and responses. It is commonly used for logging, exception handling, request interception, and caching.

  1. What are IOC, DI, and AOP? Why use them? How to use them?

Reference: https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection

IOC (Inversion of Control) is a concept that hands over the concrete implementation of classes to an external container instead of the class instantiating directly. Through this inversion, control is transferred to the external container, reducing coupling between classes.

DI (Dependency Injection) is the concrete implementation of IOC. It is responsible for combining dependencies between classes. There are three lifetimes:

  • Transient: Services are always different; a new instance is created each time the service is requested.
  • Scoped: Services change only with a new scope, but are the same instance within a scope.
  • Singleton: Services are always the same; a new instance is created only once.

Native DI supports constructor injection or ServiceProvider.CreateScope.GetService to obtain instances. If you need extended injection, you can use Autofac.

AOP (Aspect-Oriented Programming) is a technology that achieves unified maintenance of program functionality through pre-compilation and runtime dynamic proxies. My understanding is that it dynamically maps DLLs at runtime to obtain class instances.

  1. EF Core and ORM related

Reference: https://blog.csdn.net/u011854789/article/details/72783902

Answer: ORM (Object-Relational Mapping) refers to the conversion between an object-oriented object model and the data structure of a relational database. EF has three programming methods: Database First, Model First, and Code First.

  1. For multithreading, see this: https://www.yuque.com/zhanglin-l1ak6/ll06t7/tkq97k

  2. For Redis interview questions, see this: https://blog.csdn.net/adminpd/article/details/122934938

  3. What is an index? What types of indexes are there (SQL Server)?

Reference: https://learn.microsoft.com/en-us/sql/relational-databases/indexes/indexes?view=sql-server-ver16

Answer: Indexes are used to speed up query performance. They allow faster retrieval of data from a table.

  1. What is a stored procedure? What are its advantages and disadvantages?

Answer: A stored procedure is a set of SQL statements designed to perform a specific function, stored in the database.

Advantages of stored procedures:

    1. High efficiency: After being compiled once, it is stored in the database and executed directly each time it is called. Ordinary SQL statements are saved elsewhere (e.g., in a text file) and need to be analyzed and compiled before execution. Therefore, stored procedures are more efficient.
    1. Reduced network traffic: Once compiled, stored procedures are stored in the database. When called remotely, large amounts of string-type SQL statements are not transmitted.
    1. High reusability: Stored procedures are often written for a specific function. When that function is needed again, the stored procedure can be called again.
    1. High maintainability: When functional requirements change slightly, modifying the existing stored procedure is relatively easy and requires less effort.
    1. High security: Stored procedures for specific functions are usually only usable by specific users, providing identity restrictions for greater security.

Disadvantages of stored procedures:

  • Each database has nearly different syntax for stored procedures, making them very difficult to maintain (not universal).
  • Putting business logic in the database makes iteration difficult.

Manual write:

create proc StuProc
@sname varchar(100)
begin
select S#,Sname,Sage,Ssex from student where sname=@sname
end
go
exec StuProc 'Zhao Lei' //execute statement
  1. What is a deadlock? How to avoid it?

Answer: A deadlock is a situation where two or more processes are waiting for each other to release resources, causing them to be stuck indefinitely. Without external intervention, they cannot proceed. To avoid deadlocks: access objects in the same order, avoid user interaction within transactions, keep transactions short and within a single batch, and design indexes properly to avoid full table scans.

  1. SQL Server function creation: https://www.cnblogs.com/Brambling/p/6686947.html

  2. What is a transaction? What are its characteristics?

Answer: A transaction is a mechanism, a sequence of operations, containing a set of database operation commands. A transaction submits or rolls back all commands as a single unit, meaning either all commands execute or none do. Therefore, a transaction is an indivisible logical unit of work. It has four properties: Atomicity, Consistency, Isolation, and Durability, often abbreviated as ACID.

Frontend part: Vue basics, component communication and reuse, differences from jQuery, JavaScript syntax, JavaScript basics, common UI frameworks, etc.

Also asked about caching middleware, message middleware, logging middleware (log reporting and statistics), database sharding, cache persistence and consistency, master-slave synchronization, read-write separation, B+ trees, red-black trees, B-trees, etc.

Keep Exploring

Related Reading

More Articles