0% found this document useful (0 votes)
24 views2 pages

C# Interview Questions and Answers Guide

Uploaded by

Sopheak Uk
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

C# Interview Questions and Answers Guide

Uploaded by

Sopheak Uk
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C# .

Net Interview

1. What is meant by garbage collection in C#?


2. What is a destructor in C#?
3. What is a constant in C#?
4. What is the difference between value type and reference type?
5. What are the different types of classes in C#?
6. What is the difference between fields and properties in C#?
7. What is method overloading in C#?
8. What are boxing and unboxing in C#?
9. What is the difference between ref and out keywords in C#?

10. What are the advantages of generics in C#?

11. When should multithreading be used and when should it be avoided in C#?
12. How would you explain the four fundamental concepts of object-oriented
programming?
13. When is method overriding used in C#?
14. What is the difference between overriding and overloading keywords in C#?
15. What is the difference between Const and ReadOnly keywords in C#?
16. What is meant by dependency injection in C#?
17. What is the difference between an interface and an abstract class in .NET?
18. What are the different types of collections available in the [Link]
namespace?
19. What are extension methods in C# and how are they used?
20. What is .NET Core and how does it differ from the .NET Framework?
21. What are the advantages of using Entity Framework Core over traditional [Link]?
22. Explain the concept of dependency injection and how it is used in .NET.
23. Explain the concept of asynchronous programming in .NET.
24. What is a Relational Database Management System?
25. How does a Relational Database Management System differ from a Database
Management System?
26. What are some of the most popular Relational Database Management Systems?
27. What is the role of SQL?
28. What are join clauses?
29. What is the role of indexes?
30. How is the cursor used in SQL?
31. What are the key differences between the DELETE and TRUNCATE SQL commands?
32. What are some of the most important aggregate functions?
33. What are SQL injections and how can they be prevented?
34. What are the main differences between HAVING and WHERE SQL clauses?
35. Discuss how the .NET MAUI framework supports different platforms, such as iOS,
Android, Windows and macOS. What are the pros and cons of using a single cross-
platform framework like .NET MAUI?
36. What is .NET MAUI?
37. What are the key features of .NET MAUI?
38. What are the advantages of using .NET MAUI for cross-platform development?
39. How does dependency injection work in .NET MAUI?
40. Can you explain the concept of Hot Reload in .NET MAUI?

Common questions

Powered by AI

Method overriding in C# is a feature that allows a derived class to provide a specific implementation of a method already defined in its base class. It is achieved using the 'override' keyword. This process enables polymorphism by allowing different classes to run different implementations of the same method, enhancing flexibility and maintainability in code design. Polymorphism via overriding allows for dynamic method dispatch, which is integral to object-oriented programming patterns .

.NET MAUI (Multi-platform App UI) facilitates cross-platform development by allowing developers to use a single codebase to create applications that run natively across multiple platforms such as iOS, Android, Windows, and macOS. This streamlines development, reduces duplicated effort, and offers a consistent look and feel across platforms. Key benefits include code reusability, reduced development time, and unified tooling. However, drawbacks include potential performance limitations and platform-specific feature limitations that may require additional customization .

Interfaces in C# declare a contract with method signatures but do not include method implementations, while abstract classes can include both member declarations and implementations. Interfaces support multiple inheritances, while a class can only inherit from one abstract class. You would choose an interface when you need to define a common API for unrelated classes and when multiple inheritance is required. An abstract class is more appropriate when you need to provide a common base with default behavior that can be reused by derived classes .

Garbage collection in C# is a process that automatically handles memory management by identifying and disposing of objects that are no longer needed by the application. This process helps prevent memory leaks and optimizes the use of available memory, which can improve application performance by freeing up resources held by unreferenced objects. However, excessive garbage collection can lead to application pauses and can impact performance negatively, so developers must be mindful of memory usage patterns .

Value types in C# store data directly and are stored in the stack, while reference types store a reference to the data in the heap. This distinction is crucial because it affects memory allocation, copying of data, and performance. Value types are typically used for smaller, single-value data types like integers and structs, and when a value type is copied, a complete copy of the value is made. In contrast, copying a reference type only copies the reference to the original data, not the data itself, which can lead to side effects if the data is modified. Understanding these differences is important for effective memory management and application performance tuning .

Multithreading in C# should be used to improve application responsiveness and performance when tasks can be executed concurrently, such as performing input/output operations or background processing without obstructing the main thread. It is particularly beneficial in scenarios with resource-intensive computations that can benefit from parallel execution. However, it should be avoided when managing shared resources is difficult because improper synchronization can lead to race conditions or deadlocks, and when the task requires significant overhead to manage threads, which can outweigh the performance benefits .

.NET Core is a cross-platform, open-source framework designed for modern infrastructure, while the .NET Framework is Windows-specific and more mature. The advantages of using .NET Core include cross-platform capability, modular architecture that allows using only necessary components, improved performance and scalability, and active community support. These features make .NET Core suitable for modern apps that require flexibility and diverse deployment environments .

Dependency injection in .NET allows components to receive their dependencies from an external source rather than creating them directly, promoting loose coupling and better testability. In contrast, direct instantiation involves components creating their own dependencies, leading to tight coupling and difficulty in testing. The benefits of dependency injection include simplified testing by allowing mock implementations, improved code maintainability by reducing hard-coded dependencies, and enhanced flexibility through easy configuration changes .

SQL injections are security vulnerabilities that allow attackers to interfere with the queries that an application makes to its database. An attacker can manipulate a SQL statement through input fields to execute unauthorized commands, potentially bypassing authentication and accessing sensitive data. Prevention strategies include using parameterized queries and prepared statements, which separate SQL logic from data input, employing stored procedures, and validating and sanitizing user inputs to ensure they do not contain harmful SQL code .

Generics in C# allow developers to define classes, methods, and data structures with a placeholder for the data type, which can be specified later when the code is instantiated or invoked. This improves code reusability by enabling code to work with any data type and enhances type safety by ensuring compile-time type checking. For example, a generic list (List<T>) can store any type of object without needing multiple versions of the list class for each data type, which reduces redundancy and potential for errors .

You might also like