-
-
-
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) { }
-
-
X=X+1 is equivalent to
A) X++B) X+=1C) Both A & B
-
-
A class type in C# is a value type
Skill/Topic: BeginnerA) YesB) NoExplanation: It is a reference type
-
Assemblies cannot be loaded side by side
A) TrueB) FalseExplanation: Assemblies can be loaded side by side
-
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() {}}
-
How do I create a multilanguage, single-file assembly?
This is currently not supported by Visual Studio .NET.
-
-
-
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 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);}
-
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.
-
-
-
-
C# Interview Questions
Ans