Thursday, May 26, 2011

What is the difference between abstraction and encapsulation?

Abstraction:
Abstraction lets you focus on what the object does instead of how it does it

That means we use the object without knowing the source code of the class.

Encapsulation:
Encapsulation means hiding the internal details or mechanics of how an object does something.

Encapsulation is wraping data into single unit.


Wednesday, May 18, 2011

What is the difference between classes and structs in Microsoft.Net?

  • A struct is a value type, while a class is a reference type.
  • When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack.
  • Classes can have explicit parameter less constructors. But structs cannot have this.
  • Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces.
  • We can assign null variable to class. But we cannot assign null to a struct variable, since structs are value type.
  • We can declare a destructor in class but can not in struct.

Saturday, May 14, 2011

Sql-Server, find Duplicate Rows with Count

select Count(ID), Name, Email,Comment
FROM TableName     
group by Name, Email,Comment
having Count(ID)>1