-
The assembly class is defined in
A) System.ReflectionB) SystemC) System.InteropServices
-
What is the output of Vectors.RemoveAt(1)
A) Removes the object whose key is 1B) Removes the object whose value is 1C) Removes the object at position 1
-
Why does DllImport not work for me?
All methods marked with the DllImport attribute must be marked as public static extern.
-
-
The condition for If statement in C# is enclosed with in
A) ( )B) { }C) [ ]
-
Why do I get an error (CS1006) when trying to declare a method without specifying a return type?
If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 errorpublic static staticMethod (mainStatic obj)// This will work as wantedpublic static void staticMethod (mainStatic obj)
-
-
What is the role of the DataReader class in ADO.NET connections?
It returns a read-only dataset from the data source when the command is executed.
-
How can you overload a method?
Different parameter data types, different number of parameters, different order of parameters.
-
How is method overriding different from overloading?
When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.
-
-
What is the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
-
-
Is there a way of specifying which block or loop to break out of when working with nested loops?
The easiest way is to use goto: using System;class BreakExample {public static void Main(String[] args) {for(int i=0; i<3; i++) {Console.WriteLine("Pass {0}: ", i);for( int j=0 ; j<100 ; j++ ) {if ( j == 10) goto done;Console.WriteLine("{0} ", j);}Console.WriteLine("This will not print");}done:Console.WriteLine("Loops complete.");}}
-
Can you declare the override method static while the original method is non-static?
No, you cannot, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.
-
-
-
What does Dispose method do with the connection object?
Deletes it from the memory.
-
Why does my Windows application pop up a console window every time I run it?
Make sure that the target type set in the project properties setting is set to Windows Application, and not Console Application. If you're using the command line, compile with /target:winexe & not /target:exe.
-
C# Interview Questions
Ans