C# (Sharp) Programming Language Question:

Download Job Interview Questions and Answers PDF

What optimizations does the C# compiler perform when you use the /optimize+ compiler option?

C# (Sharp) Programming Language Interview Question
C# (Sharp) Programming Language Interview Question

Answer:

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.

Download C# (Sharp) Programming Language Interview Questions And Answers PDF

Previous QuestionNext Question
What does the keyword virtual mean in the method definition?How can I create a process that is running a supplied native executable (e.g., cmd.exe)?