Interview questions for C# developers
-
If I return out of a try/finally in C#, does the code in the finally-clause run? - Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs:
Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block).
-
Is it possible to inline assembly or IL in C# code? - No.
-
Is it possible to have a static indexer in C#? - No. Static indexers are not allowed in C#.
-
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) { }
-
How do you directly call a native function exported from a DLL? -
-
This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.
-
How do I simulate optional parameters to COM calls? - You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.
-
How do you specify a custom attribute for the entire assembly (rather than for a class)? - Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:
using System;[assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.
Recent Posts
- Error message when you try to install SQL Server 2008 if the path of the SQL Server 2008 installation media contains a number sign (#) character: “Could not load file or assembly ‘<Path>\Mi …
- Employee Performance Appraisal System: An Overview
- CMYK versus RGB color spectrum
- Description of the Jet 4.0 Database Engine hotfix package for Windows XP SP2, Windows Server 2003 SP1, Windows Server 2003 SP2, Windows Vista, Windows Vista SP1, and Windows Server 2008: October …
- Adobe training in Sydney from Creative Mentor
- Business Card Do's and Don'ts
- Unique Gifts – Chalk Mugs
- Turn One Of The Bahamas Houses For Sale As A Holiday Home
- Tips To Hire A Professional Web Design Company
- The 10 Factors That Affect and Predict Stock Prices
Tag Cloud
-
application
ASP
assembly
career
class
code
company
constructor
control
Database
difference
Don
employer
error
Exception
hiring manager
information
interview
interviewer
job
job seekers
manager
method
NET
page
person
position
Process
property
question
quot
response
Serialization
Server
session state
site
SQL
State
system
time
type
void
way
web
work
BlogRoll
Archives
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009