-
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() {}}
-
From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?
With regard to versioning, interfaces are less flexible than classes. With a class, you can ship version 1 and then, in version 2, decide to add another method. As long as the method is not abstract (i.e., as long as you provide a default implementation of the method), any existing derived classes continue to function with no changes. Because interfaces do not support implementation inheritance, this...
-
What optimizations does the C# compiler perform when you use the /optimize+ compiler option?
The following is a response from a developer on the C# compiler team: We get rid of unused locals (i.e., locals that are never read, even if assigned).We get rid of unreachable code.We get rid of try-catch w/ an empty try.We get rid of try-finally w/ an empty try (convert to normal code...).We get rid of try-finally w/ an empty finally (convert to normal code...).We optimize branches over branches:...
-
How can I create a process that is running a supplied native executable (e.g., cmd.exe)?
The following code should run the executable and wait for it to exit before continuing: using System;using System.Diagnostics;public class ProcessTest {public static void Main(string[] args) {Process p = Process.Start(args[0]);p.WaitForExit();Console.WriteLine(args[0] + " exited.");}} Remember to add a reference to System.Diagnostics.dll when you compile.
-
What is the data provider name to connect to Access database?
Microsoft.Access.
-
Why do I get a "CS5001: does not have an entry point defined" error when compiling?
The most common problem is that you used a lowercase 'm' when defining the Main method. The correct way to implement the entry point is as follows: class test {static void Main(string[] args) {}}
-
When you inherit a protected class-level variable, who is it available to?
Classes in the same namespace.
-
-
Bool data type in C# is
Skill/Topic: BeginnerA) a value typeB) a reference type
-
An int in C# is
Skill/Topic: BeginnerA) 16 bit unsigned integerB) 32 bit signed integerC) 64 bit integer
-
A struct is a
Skill/Topic: BeginnerA) value typeB) a reference type
-
Which tool is used to browse the classes, structs, interfaces etc. in the BCL?
Skill/Topic: IntermediateA) csc.exeB) bcl.exeC) WinCV
-
From command line, a C# program can be compiled using
Skill/Topic: BeginnerA) csc.exeB) csharp.exeC) compilescs.exe
-
The methods which can be called without instantiating an object first are called
Skill/Topic: IntermediateA) staticB) dynamicC) primary
-
What is an assembly?
Skill/Topic: IntermediateA) A logical unit containing complited codeB) A collection of C# compilersC) .NET debugger
-
To start a Thread, you call the following method
Skill/Topic: IntermediateA) Start()B) Begin()C) Jump()
-
System is a
Skill/Topic: IntermediateA) ClassB) NamespaceC) Program
-
The following type of class can’t be instantiated
Skill/Topic: IntermediateA) absoluteB) abstractC) superD) none of the above
-
'Reflection' is used to
Skill/Topic: AdvancedA) Get assembly metadata using codeB) Debug C# programsC) Compile C# programs
-
A virtual method can’t be over ridden
Skill/Topic: IntermediateA) TrueB) False
C# Interview Questions
Ans