You would know that System.Object is the parent class of all .NET classes; In other words all types in .NET (whether implicit, explicit, or user-created) derive from the System.Object class. What are the various methods provided to System.Object’s deriving classes/types?

System.Object provides the following important methods, among others: ToString—Returns a string that represents the current object both overrides of Equals(object), Equals(object, object) GetHashCode Finalize GetType ReferenceEquals MemberwiseClone Most of these methods provide the basic implementation required of any type that a developer will work with in the .NET stack. In .NET, the System.Object class provides … Read more

When break is used inside two nested for loops, control comes out of which loop, the inner or the outer for loop? (I.e. does it break from all the present loops?)

It breaks from the inner loop only. In C# (and in many other programming languages), when a break statement is encountered inside nested loops, it only breaks out of the innermost loop. The outer loop continues its iterations unaffected. So, the control comes out of the inner loop, not the outer loop. Here’s a simple … Read more

Why can’t you specify access modifiers for items in an interface?

It is always public In .NET interviews, when asked why you can’t specify access modifiers for items in an interface, you can explain it with the following points: Interface Nature: An interface in .NET serves as a contract defining a set of members (properties, methods, events) that implementing classes must provide. It’s a blueprint for … Read more

How do you implement a generic action in WebAPI?

It’s not possible, as the WebAPI runtime needs to know the method signatures in advance. In ASP.NET WebAPI, implementing a generic action involves creating a generic method within a controller that can handle various types of requests and responses. Here’s how you can implement a generic action in WebAPI: csharpCopy code using System; using System.Web.Http; … Read more

What is a delegate in .NET?

A delegate in .NET is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method … Read more