C# Jaguar || Csharp Jaguar

To know what is C# Jaguar, watch our first introduction video given right below. To watch more videos on ASP.NET tutorials, C# tutorials and tutorials on other Microsoft Technology and Tools, Please go to our channel C# Jaguar on Youtube.

click here to subscribe

Important ASP.NET C# Interview Questions

ASP.NET Interview Question 1

When to choose string and when to choose StringBuilder?

This question can also be asked as what is better in string and StringBuilder? Answer is when it comes to performance, in case you need to do multiple operations like concatenation where you would change the size of string multiple times. Then you should definitely choose StringBuilder over string. string is immutable. It means once you set a string object, If you want to do some operation like concatenation on this object then previous object gets destroyed and a new fresh string object is assigned with updated value. So to resolve this we should always use StringBuilder which is mutable if number of operations on string are significant. If there are not so much operations involved then you can keep using string object.

ASP.NET Interview Question 2

When to choose for loop and when to choose while loop?

So for is countable loop or you can say finite loop. In case of for loop we know how many times a loop will execute. But While loop is considered an infinite iteration. Based on a condition it can keep running till the condition is true. In case of while loop, knowing number of iteration is bit difficult hence it is also considered infinite loop. Now when to choose which one? In case you know how many times a loop is going to be executed then go for for loop. If you are not sure on how many times the iteration should happen but you know a condition till which iteration should happen then go for while loop.

ASP.NET Interview Question 3

What does the "volatile" keyword in C# mean?

When we use volatile keyword in front of a variable then it tells compiler that this variable is prone to change its value any time. This variable should not be cached. So if on a resource multiple threads are working and they are setting and accessing the variable frequently then we should keep that field or property of class as volatile.

    class VolatileTest
    public volatile int sharedResource;

    public void Test(int _i)
        sharedResource = _i;

ASP.NET Interview Question 4

In which event of ASP.NET page life cycle is the ViewState available?

After the Init() and before the Page_Load().

ASP.NET Interview Question 5

What is the difference between Assert.AreEqual and Assert.AreSame?

AreSame() checks that they are the exact same object - if reference indicate the same object in memory.
AreEqual() checks that objects has equal type and value. Equal objects can exist in two different places in memory.
Assert.AreEqual(obj1, obj2) is the same as Assert.IsTrue(Object.Equals(obj1, obj2))
Assert.AreSame(obj1, obj2) is the same as Assert.IsTrue(Object.ReferenceEquals(obj1, obj2))

ASP.NET Interview Question 6

What is .Net framework?

It is a platform for building various applications on windows operating system. It has a list of inbuilt functionalities in the form of class, library, and APIs which are used to build, deploy and run web services and different applications. It supports different languages such as C#, VB .Net, Cobol, Perl, etc. This framework supports object-oriented programming model like Java.

ASP.NET Interview Question 7

What is MVC

MVC stands for Model View Controller. It is an architectural model for building the .Net applications.
Models – Model objects store and retrieve data from the database for an application. If you want to get a logically related data on the view from controller then we create a model for our view and while returning the view from controller, we also return model with view. They are usually the logical parts of an application that is implemented by the application’s data domain.
View – These are the components that display the view of the application in the form of UI. The view gets the information from the model objects for their display. They have components like buttons, drop boxes, combo box, etc.
Controllers – They handle the User Interactions. They are responsible for responding to the user inputs, work with the model objects, and pick a view to be rendered to the user.

ASP.NET Interview Question 8

Which of the following are applicable for overloading?

a) Constructors
b) Methods
c) Both a & b
d) None of the mentioned
Answer: Option C Both Constructors and Methods

ASP.NET Interview Question 9

Which of the following keyword is used when a virtual method is redefined by a derived class?

a) overloads
b) override
c) overridable
d) virtual
e) base
Answer: Option b override

ASP.NET Interview Question 10 - SQL

List major differences between Stored Procedure and Function.

Stored Procedure:
A Stored procedure is always used to perform a specific task.
It can return zero, one or more value.
It can have both Input and Output Parameters.
Exception handling can be done using a try-catch block.
A function can be called from a Procedure.

Functions must return a single value.
It can only have the input parameter.
Exception handling cannot be done using a try-catch block.
A Stored procedure cannot be called from a function.

C# Interview Question Series by Csharp Jaguar

Learn when to use interface and when to use abstract class in C# programming.

How To Create A Console App using C# in Visual Studio

click here to subscribe

Powered by Kapil Dev Gaur