Wednesday, 30 March 2011

Difference between Equal() and ==

  • Equals() method compares the state of an object i.e. it compares the contents of the two objects.
  • == compares the instance of the object i.e. it comparing the identifier(references).

Example :
 
string s1 = "test";
string s2 = "test";
string s3 = new string(new char[] { 't', 'e', 's', 't' });
object s4 = s3;
Console.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s2), s1 == s2, s1.Equals(s2));
Console.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s3), s1 == s3, s1.Equals(s3));
Console.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s4), s1 == s4, s1.Equals(s4));

Output :

True True True
False True True
False False True

Ref: here, here

Monday, 28 March 2011

Difference between Abstract classes and Interface

  • Abstract Class
    • A class may inherit only one abstract class.
    • An abstract class can contain access modifiers for the subs, functions, properties.
    • An Abstract class has abstract or concrete subs, functions, properties etc.
    • An abstract class can have fields and constants defined.
 
    • Interface
      • A class may inherit several interfaces, which help achieving Multiple Inheritance.
      • An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public
      • An interface can only have abstract subs, functions, properties etc
      • No fields can be defined in interface
    Ref- here, here

    Saturday, 26 March 2011

    Types of sql statements

    • DML
      • DML is abbreviation of Data Manipulation Language.
      • Examples: UPDATE, INSERT, DELETE statements
    • DDL
      • DDL is abbreviation of Data Definition Language.
      • Examples: CREATE, ALTER, DROP statements
    • DCL
      • DCL is abbreviation of Data Control Language.
      • Examples: GRANT, REVOKE statements
    • TCL
      • TCL is abbreviation of Transactional Control Language.
      • Examples: COMMIT, ROLLBACK statements
    • DQL
      • DQL is abbreviation of Data Query Language.
      • Examples: SELECT statements
    Ref: here