.Net Interview Questions and Answers for 10 years experience
-
What are the differences between .NET Framework and .NET Core (now .NET)?
- Answer: .NET Framework is a Windows-only, full-fledged framework, while .NET is cross-platform (Windows, macOS, Linux), open-source, and modular. .NET Core offered improved performance, better tooling, and a more streamlined architecture. .NET builds upon the strengths of .NET Core, unifying the platform and making it the preferred choice for most new development.
-
Explain the concept of Garbage Collection in .NET.
- Answer: Garbage Collection (GC) is an automatic memory management system in .NET. It automatically reclaims memory occupied by objects that are no longer referenced by the application. This prevents memory leaks and simplifies memory management for developers. .NET uses a non-deterministic GC, meaning it runs when it deems necessary, typically when memory pressure is high. Different GC modes (e.g., server GC, workstation GC) are available for performance tuning.
-
What are different types of Garbage Collection in .NET?
- Answer: .NET offers various garbage collection modes, including Workstation GC (suitable for client applications), Server GC (optimized for server applications with multiple cores), and Concurrent GC (aims to minimize pauses by performing collection concurrently with application execution). The choice depends on the application's requirements and performance needs.
-
Describe the different types of application domains that can be created in .NET.
- Answer: Application domains provide isolation between different parts of an application. They are primarily used in scenarios requiring enhanced security, fault tolerance, and code isolation. They're not as commonly used in modern .NET development with the advent of containerization.
-
Explain the concept of Reflection in .NET.
- Answer: Reflection allows you to inspect and manipulate metadata at runtime. You can discover the types, methods, properties, and fields of an assembly without knowing them at compile time. This is useful for dynamic code generation, object serialization, and other advanced scenarios, but it should be used judiciously as it can impact performance.
-
What are Generics in .NET and why are they useful?
- Answer: Generics allow you to write type-safe code that can work with different data types without requiring boxing and unboxing. This improves performance and code reusability. A common example is a generic list (List<T>) that can hold any type of object.
-
Explain the difference between Value Types and Reference Types in .NET.
- Answer: Value types (e.g., int, float, struct) store their data directly on the stack. Changes to a value type do not affect other variables. Reference types (e.g., class, string, object) store a reference to the data on the heap. Changes to a reference type affect all variables pointing to the same object.
-
What is the purpose of the IDisposable interface?
- Answer: The IDisposable interface is used to release unmanaged resources (like file handles, database connections, network streams) when they're no longer needed. It defines the Dispose() method, which should be called to clean up resources. The using statement simplifies this process.
-
Explain the concept of LINQ (Language Integrated Query).
- Answer: LINQ provides a consistent way to query and manipulate data from various sources (databases, XML files, in-memory collections) using C# syntax. It allows you to write declarative queries rather than imperative loops, resulting in more readable and maintainable code.
Thank you for reading our blog post on '.Net Interview Questions and Answers for 10 years experience'.We hope you found it informative and useful.Stay tuned for more insightful content!