-
-
-
-
-
-
-
-
Does C# support templates?
No. However, there are plans for C# to support a type of template known as a generic. These generic types have similar syntax but are instantiated at run time as opposed to compile time. You can read more about them here.
-
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 {CriticalSection.Enter(obj);// code} finally {CriticalSection.Exit(obj);}
-
-
How does one compare strings in C#?
In the past, you had to call .ToString() on the strings when using the == or != operators to compare the strings' values. That will still work, but the C# compiler now automatically compares the values instead of the references when the == or != operators are used on string types. If you actually do want to compare references, it can be done as follows: if ((object) str1 == (object) str2) { ... }Here's...
-
-
-
How do I create a multilanguage, single-file assembly?
This is currently not supported by Visual Studio .NET.
-
What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?
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() {}}
-
Assemblies cannot be loaded side by side
A) TrueB) FalseExplanation: Assemblies can be loaded side by side
-
A class type in C# is a value type
Skill/Topic: BeginnerA) YesB) NoExplanation: It is a reference type
-
X=X+1 is equivalent to
A) X++B) X+=1C) Both A & B
-
I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am passing to it?
You should declare the variable as an int, but when you pass it in you must specify it as 'out', like the following: int i;foo(out i);where foo is declared as follows: [return-type] foo(out int o) { }
-
Why does my Windows application pop up a console window every time I run it?
Make sure that the target type set in the project properties setting is set to Windows Application, and not Console Application. If you're using the command line, compile with /target:winexe & not /target:exe.
C# Interview Questions
Ans