What are delegates? C# interview Questions 40

What are delegates? C# interview Questions 40

Delegates in C# are type-safe function pointers that allow methods to be passed as parameters. They are used to define callback methods and implement event handling. Delegates can point to both static and instance methods, enabling flexibility and decoupling of methods from the objects that call them.

What are Custom Exceptions? C# interview Questions 39

What are Custom Exceptions? C# interview Questions 39

Custom exceptions in .NET are user-defined exceptions that inherit from System.Exception. They provide specific error information tailored to an application’s needs, improving code readability and error handling.

List down the most commonly used types of exceptions in dot NET | C# interview Questions 38

List down the most commonly used types of exceptions in dot NET | C# interview Questions 38

The most commonly used types of exceptions in .NET include: System.Exception: Base class for all exceptions. System.NullReferenceException: Thrown when attempting to use a null object reference. System.IndexOutOfRangeException: Thrown when an array index is out of bounds. System.InvalidOperationException: Thrown when a method call is invalid for the object’s current state. System.ArgumentException: Thrown when an argument provided […]

What is an object pool in dot NET? | C# interview Questions 37

What is an object pool in dot NET? | C# interview Questions 37

An object pool in .NET is a design pattern used to manage a collection of reusable objects. It aims to reduce the overhead of creating and destroying objects by reusing them. This is particularly useful for objects that are expensive to create or require significant resources. By maintaining a pool of objects, you can improve […]

What are generics in C# .NET? | C# interview Questions 36

What are generics in C# .NET? | C# interview Questions 36

Generics in C# .NET allow you to define classes, methods, and data structures with a placeholder for the type of data they store or use. This provides type safety without the need to specify an exact data type upfront, promoting code reuse and reducing runtime errors. For example, List T can store any type of […]

What are circular references? C# interview Questions 35

What are circular references? C# interview Questions 35

Circular references occur when two or more objects reference each other directly or indirectly, creating a loop. This can lead to issues such as memory leaks, as the garbage collector cannot reclaim the memory used by these objects since they are still considered in use due to their mutual references.

What is the difference between Dispose() and Finalize()methods? | C# interview Questions 34

What is the difference between Dispose() and Finalize()methods? | C# interview Questions 34

Dispose(): Purpose: Explicitly releases unmanaged resources. Usage: Called by the developer manually. Implementation: Part of the IDisposable interface. Timing: Immediate, deterministic cleanup. Finalize(): Purpose: Implicitly releases unmanaged resources. Usage: Called by the garbage collector. Implementation: Defined using a destructor syntax (~ClassName). Timing: Non-deterministic, depends on garbage collection timing. Key Difference: Dispose() is called manually for […]

Difference between the System.Array.CopyTo() and System.Array.Clone() ? | C# interview Questions 31

Difference between the System.Array.CopyTo() and System.Array.Clone() ? | C# interview Questions 31

What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ? System.Array.CopyTo(): Purpose: Copies the elements of an array to another existing array starting at a specified index. Operation: Requires a destination array with sufficient size. Usage: sourceArray.CopyTo(destinationArray, startIndex); System.Array.Clone(): Purpose: Creates a shallow copy of the array. Operation: Returns a new array with the same elements. […]