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) {}
}
What does the keyword virtual mean in the method definition?
The method can be over-ridden.
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:
gotoif A, lab1
goto lab2:
lab1:
turns into: gotoif !A, lab2
lab1:
We optimize branches to ret, branches to next instruction, and branches to 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 beforecontinuing:
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 difference between the System.Array.CopyTo() and System.Array.Clone()?
The first one performs a deep copy of the array, the second one is shallow.
Tuesday, October 14, 2008
Posted by spot your answer at 1:07 AM
Labels: C# Interview-3
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment