Set - 4

Question 1 :

Why do I get a syntax error when trying to declare a variable called checked?

Answer :

The word checked is a keyword in C#.


Question 2 :

Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

Answer :

The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.


Question 3 :

What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?

Answer :

The syntax for calling another constructor is as follows:

class B{
	B(int i)
	{ }
}
class C : B{
	C() : base(5) // call base constructor B(5)
    { }
	C(int i) : this() // call C()
    { }
	public static void Main() {}
}

 


Question 4 :

Why do I get a "CS5001: does not have an entry point defined" error when compiling?

Answer :

The most common problem is that you used a lowercase 'm' when defining the Main method. 
The correct way to implement the entry point is as follows:

class test{
	static void Main(string[] args) {}
}

 


Question 5 :

What does the keyword virtual mean in the method definition?

Answer :

The method can be over-ridden.