-
Which of the following has stream as the base class
A) Buffered StreamB) MemoryStreamC) FileStream
-
-
Public policy applies to
A) Shared assembliesB) Private assembliesC) Both
-
What happens when a C# project has more than 1 Main methods
A) Compiler throws warning messageB) Compiler throws Error messageC) Compiler successfully compiles
-
How do you refer parent classes in C#
A) SuperB) ThisC) Base
-
-
Which of the following application need not to have an entry point
A) Console applicationB) Windows applicationC) Class ModulesExplanation: Class modules are referred by another project which will have entry point.
-
It is not possible to debug the classes written in other .Net languages in a C# project.
A) TrueB) FalseExplanation: It is possible to debug the code as all are adhering to CTS & CLS
-
-
Following are the features of .NET
Skill/Topic: IntermediateA) Language InteroperabilityB) Garbage CollectionC) Multiple Inheritance
-
-
How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.
-
You can explicitly call the garbage collector
Skill/Topic: AdvancedA) TrueB) False
-
What is an indexer in C#
A) Special syntax for overloading [ ] operator for a classB) One which speeds up the function callC) None of the above
-
Describe the accessibility modifier protected internal.
It's available to derived classes and classes within the same Assembly (and naturally from the base class it's declared in).
-
C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there is no implementation in it.
-
Does C# support C type macros?
No. C# does not have macros. Keep in mind that what some of the predefined C macros (for example, __LINE__ and __FILE__) give you can also be found in .NET classes like System.Diagnostics (for example, StackTrace and StackFrame), but they'll only work on debug builds.
-
What is the equivalent to regsvr32 and regsvr32 /u a file in .NET development?
Try using RegAsm.exe. The general syntax would be: RegAsm. A good description of RegAsm and its associated switches is located in the .NET SDK docs. Just search on "Assembly Registration Tool".
-
How can I get around scope problems in a try/catch?
If you try to instantiate the class inside the try, it'll be out of scope when you try to access it from the catch block. A way to get around this is to do the following: Connection conn = null; try {conn = new Connection();conn.Open();}finally{ if (conn != null) conn.Close(); }By setting it to null before the try block, you avoid getting the CS0165 error (Use of possibly unassigned local variable...
-
Why do I get a security exception when I try to run my C# app?
Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what's happening, just move the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is System.Security.SecurityException.To...
C# Interview Questions
Ans