C# Interview Questions and Answers
C# Interview Questions and Answers
Example:
//This is a single line comment
ii. Multiple line (/* */)
Example:
/*This is a multiple line comment
We are in line 2
Last line of comment*/
iii. XML Comments (///).
Example:
/// summary;
/// Set error message for multilingual language.
/// summary
5) What is an object?
An object is an instance of a class through which we access the methods
of that class. “New” keyword is used to create an object. A class that
creates an object in memory will contain the information about the
methods, variables, and behavior of that class.
6) Define Constructors
A constructor is a member function in a class that has the same name as
its class. The constructor is automatically invoked whenever an object
class is created. It constructs the values of data members while
initializing the class.
pTutor.SetTutorial(1,".Net by Guru99");
Console.WriteLine(pTutor.GetTutorial());
Console.ReadKey();
}
}
}
User Controls are very much similar to ASP include files, and are easy to
create. User controls can’t be placed in the toolbox and dragged –
dropped from it. They have their design and code-behind. The file
extension for user controls is ascx.
Eg:
try {
GetAllData();
}
catch (Exception ex) {
}
In the above example, we can omit the parameter from catch
statement.
34) What is the base class in .net from which all the
classes are derived from?
System.Object
Eg:
public int this[int index] // Indexer declaration
Eg:
Public sealed class Singleton
{
Private static readonly Singleton _instance = new Singleton();
}
namespace DemoApplication
{
class Program
{
static void Main(string[] args)
{
Queue qt = new Queue();
qt.Enqueue(1);
qt.Enqueue(2);
qt.Enqueue(3);