Set - 5

Question 11 :

Is there any sample C# code for simple threading? 

Answer :

Some sample code follows:

using System;
using System.Threading;
class ThreadTest{
	public void runme(){
		Console.WriteLine("Runme Called");
	}
	public static void Main(String[] args){
		ThreadTest b = new ThreadTest();
		Thread t = new Thread(new ThreadStart(b.runme));
		t.Start();
	}
}

 


Question 12 :

What is the difference between // comments, /* */ comments and /// comments?

Answer :

Single-line, multi-line and XML documentation comments.


Question 13 :

What is the difference between and XML documentation tag? 

Answer :

Single line code example and multiple-line code example.

Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources). 

What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).


Question 14 :

How do you inherit from a class in C#?

Answer :

Place a colon and then the name of the base class. Notice that it is double colon in C++.


Question 15 :

How do I port "synchronized" functions from Visual J++ to C#?

Answer :

Original Visual J++ code:

public synchronized void Run(){
	// function body
}

Ported C# code:

class C{
	public void Run(){
		lock(this){
			// function body
		}
	}
	public static void Main() {}
}