-
What does Dispose method do with the connection object?
Deletes it from the memory.
-
-
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.
-
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.");}}
-
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.
-
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.
-
How can you overload a method?
Different parameter data types, different number of parameters, different order of parameters.
-
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.
-
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)
-
The condition for If statement in C# is enclosed with in
A) ( )B) { }C) [ ]
-
-
Why does DllImport not work for me?
All methods marked with the DllImport attribute must be marked as public static extern.
-
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
-
The assembly class is defined in
A) System.ReflectionB) SystemC) System.InteropServices
-
-
What is the difference between shadow and override
Override id used for variables and methods but override only used for methods.
-
1. Are there some features of C# language not supported by .NET?
Skill/Topic: AdvancedA) YesB) NoExplanation: For example some instances of operator overloading!
-
-
-
What is the difference between the System.Array.CopyTo() and System.Array.Clone()?
The first one performs a deep copy of the array, the second one is shallow.
C# Interview Questions
Ans