About Me

All about Real time requirements in Orale Stay Tune!!
Showing posts with label C# INTERVIEW QUES-6. Show all posts
Showing posts with label C# INTERVIEW QUES-6. Show all posts

Sunday, April 6, 2008

C# INTERVIEW QUESTIONS

Is there an equivalent of exit() for quitting a C# .NET application?

Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it's a Windows Forms app.

Can you prevent your class from being inherited and becoming a base class for some other classes?

Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java.

Is XML case-sensitive?

Yes, so and are different elements.

If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?

Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

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 I make a DLL in C#?

You need to use the /target:library compiler option.

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.