C# Interview Question

There are many things that you can do ahead of time to prepare for the interviewing process, and move yourself a step above of the competition. Updating your resume and reviewing frequently asked interview questions can be very effective, and goes a long way in getting the most out of your interview.

Why do I get a security exception when I try to run my C# app?
Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what's happening, just move the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is
System.Security.SecurityException.
To get around this, you can change your security policy for the intranet zone, code group 1.2, (the zone that running off shared folders falls into) by using the caspol.exe tool.

 

Is there any sample C# code for simple threading?
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();
}
}

 

What is the difference between // comments, /* */ comments and /// comments?
Single-line, multi-line and XML documentation comments.

 

What is the difference between and XML documentation tag?
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).

 

How do you inherit from a class in C#?
Place a colon and then the name of the base class. Notice that it is double colon in C++.

 

How do I port "synchronized" functions from Visual J++ to C#?
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() {}
}