Wednesday, January 5, 2011

Difference between abstract class and interface

1. Multiple inheritance is not possible in abstract class, but multiple inheritance is possible in interface.
2. The access modifier is public by default in interface but access modifier need not be only public in abstract class.
3. An abstract class can have a constructor but an interface doesnt have a constructor.
4. An interface can have only the signature but an abstract class can provide a default implementation
5. No fields can be defined in interface, but an abstract class can contain fields and constants

When to use an abstract class or interface

* If you are to provide a common functionality to unrelated class then use an interface
* If you plan on updating the base class throughout the life of the program its best to keep the class as abstract.
*if you are providing any default functionality then abstract class can be used.

Tuesday, July 20, 2010

Difference between Delete and Truncate statement in SQL

The difference between TRUNCATE and DELETE are as follows

Truncate

Delete

De allocation of datapages

Datapages are not deallocated

Where clause cannot be used in a truncate statement

Where clause can be used in a delete statement

Truncate will not work on tables referenced by one or more FOREIGN key constraint

Delete will work

When you truncate if the table contains an identity column then the counter for that column is reset to the seed value.

Identity counter is not resetted

Less transaction log space is used

It removes one row at a time and saves an entry into the transaction log for each deleted row

Each row is not locked when truncate is used, instead a table or a page is locked

When deleted using a row lock each row in the table is locked

Truncate cannot activate a trigger for a table

Delete can activate a trigger

Sunday, May 2, 2010

Disable Maximize in WPF Window

Recently i encountered an issue regarding disabling maximize in WPF Window ,there are few ways of doing this

set ResizeMode="CanMinimize" for the window.
or
WindowStyle="None" setting this property removes maximize, minimize and close options.