C# Interview Question :-

C# Interview Question :-

1)Virtual function in c# with example?

Virtual functions implement the concept of polymorphism are the same as in C#, except that you use the override keyword with the virtual function implementaion in the child class. The parent class uses the same virtual keyword. Every class that overrides the virtual method will use the override keyword.


class Shape{    public virtual void Draw()    {        Console.WriteLine("Shape.Draw")    ;    }}class Rectangle : Shape{    public override void Draw()    {        Console.WriteLine("Rectangle.Draw");    }}

2)How to Do File Exception Handaling in C#?
Exception handling is an in built mechanism in .NET framework to detect and handle run time errors. The .NET framework contains lots of standard exceptions. The exceptions are anomalies that occur during the execution of a program. They can be because of user, logic or system errors. If a user do not provide a mechanism to handle these anomalies, the .NET run time environment provide a default mechanism, which terminates the program execution


 3)What’s the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.

4)What’s 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.

5)What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?
 A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.


6)Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.

7)What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft.
OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines

8)What is a pre-requisite for connection pooling?
 Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.


9)What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.  The CopyTo() method copies the elements into another existing array.  Both perform a shallow copy.  A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.  A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.
10) What’s the difference between an interface and abstract class?
In an interface class, all methods are abstract - there is no implementation.  In an abstract class some methods can be concrete.  In an interface class, no accessibility modifiers are allowed.  An abstract class may have accessibility modifiers




ASP.NET:-

1)How can we check if all the validation control are valid and proper?

Using the Page.IsValid () property you can check whether all the validation are done.

2)If client side validation is enabled in your Web page, does that mean server side code is not run.
When client side validation is enabled server emit’s JavaScript code for the custom validators. However, note that does not mean that server side checks on custom validators do not execute. It does this redundant check two times, as some of the validators do not support client side scripting.

3)How to disable client side script in validators?
Set ‘EnableClientScript’ to false.

4)How can we kill a user session?
Session abandon

5)Explain the differences between Server-side and Client-side code?

Server side code is executed at the server side on IIS in ASP.NET framework, while client side code is executed on the browser.

6)How do I sign out in forms authentication?
FormsAuthentication.Signout ()

7)How can we force all the validation control to run?
Page.Validate


What is the use of command objects?

In order to execute Sql commands and stored procedures we
need command objects

What are the two fundamental objects in ADO.NET?
DataSet and DataReader are the tow funadamental object in
ADO.NET

No comments:

Post a Comment

Plz Share your comments...