Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Android app on Google Play

Technical Interview Questions
Visual Basic Interview Question
ASP .NET Interview Questions
C++ Interview Questions
C Interview Questions

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions

C Tutorial
C++ Tutorial

Programming Source Codes
C/C++ Source Codes
C# Source Codes

Soft Skills
Communication Skills
Leadership Skills




C# Interview Questions and Answers

How do you mark a method obsolete?
[Obsolete] public int Foo() {...}
[Obsolete(\"This is a message describing why this method is obsolete\")] public int Foo() {...}
Note: The O in Obsolete is always capitalized.

How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?
You want the lock statement, which is the same as Monitor Enter/Exit:
lock(obj) { // code }

translates to

try {
// code

How do you directly call a native function exported from a DLL?
Here’s a quick example of the DllImport attribute in action:

using System.Runtime.InteropServices; \
class C
public static extern int MessageBoxA(int h, string m, string c, int type);
public static int Main()
return MessageBoxA(0, \"Hello World!\", \"Caption\", 0);

This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.

How do I simulate optional parameters to COM calls? [_private/tbl_gglapck.htm]

You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters. 

What do you know about .NET assemblies?
Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.

What’s the difference between private and shared assembly?
Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

What’s a strong name?
A strong name includes the name of the assembly, version number, culture identity, and a public key token.

How can you tell the application to look for assemblies at the locations other than its own install?
Use the directive in the XML .config file for a given application.
< probing privatePath=c:\mylibs; bin\debug />
should do the trick. Or you can add additional search paths in the Properties box of the deployed application.

How can you debug failed assembly binds?
Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched.

Where are shared assemblies stored?
Global assembly cache.

How can you create a strong name for a .NET assembly?
With the help of Strong Name tool (sn.exe).

Where’s global assembly cache located on the system?
Usually C:\winnt\assembly or C:\windows\assembly.

Can you have two files with the same file name in GAC?
Yes, remember that GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version and the second one is

Page Numbers :   1         2         3         4         5         6        7        8        9       10         11          12          13          14         15        16

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Object Oriented Interview Questions for more Object Oriented Interview Questions with answers

Check Data Structure Interview Questions for more data structure interview questions with answers