Friday, May 15, 2020

What is Interface?

What is Interface?
  1. An interface can contain signatures (declarations) of the Methods, Properties, Indexers and Events.
  2. The implementation of the methods is done in the class that implements the interface.
  3. A Delegate is a type that can't be declared in an interface. You can either use an event (if appropriate) or declare a delegate outside the interface but in the same namespace.
  4. Interfaces in C# provides a way to achieve runtime polymorphism. Using interfaces, we can invoke functions from various classes through the same Interface reference, whereas using virtual functions we can invoke functions from various classes in the same inheritance hierarchy through the same reference.
  5. An interface can inherit from one or more base interfaces.
  6. A class that implements an interface can explicitly implement members of that interface.
  7. An explicitly implemented member cannot be accessed through a class instance, but only through an instance of the interface.
Purposes of Interfaces
  1. Create loosely coupled software.
  2. Support design by contract (an implementer must provide the entire interface).
  3. Allow for pluggable software.
  4. Allow objects to interact easily.
  5. Hide implementation details of classes from each other.
  6. Facilitate reuse of software.

What is the difference between a Local and a Global temporary table?

What is the difference between a Local and a Global temporary table?

Temporary tables are used to allow short term use of data in SQL Server. They are of 2 types:

Local
- Only available to the current Db connection for current user and are cleared when connection is closed.
- Multiple users can’t share a local temporary table.

Global
- Available to any connection once created. They are cleared when the last connection is closed.
- Can be shared by multiple user sessions.

What is the difference between a Local and a Global temporary table?

A local temporary table lives until the connection is valid or until the duration of a compound statement.

A global temporary table is permanently present in the database. However, the rows of the table are present until the connection is existent. Once the connection is closed, the data in the global temporary table disappears. However, the table definition remains with the database for access when database is opened next time.