LINQ (Language Intergrated Query)

LINQ is a new type-safe query structure available in C# 3.0 and .NET 3.5 Microsoft framework.  With LINQ you can query against any collection that implements IEnumerable<> or remote data sources.  With this, LINQ benefits from compile-time checking and dymanic query composition.  To use LINQ include the following namespaces from System.Core assembly:

System.Linq
System.Linq.Expressions

LINQ consists of 2 basic data units, sequences and elements.  A sequence is defined as any object implementing the IEnumerable and elements are any item within the sequence.

To transform a sequence you use a method called query operator, which typical accept an input sequence and produce an output sequence.  The IEnumerable class in LINQ has around 40 or so query operators that are refered to as standard query operators.

A standard query expression would look as follows:

C#
using System;
using System.Collections.Generic;
using System.Linq;
namespace LINQSample
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] query = { "I", "Was", "Here" };  //String collection to query
            IEnumerable<string> filteredQuery = query.Where(n => n.Length >= 1);  //query with lambda expression.
            foreach (string q in filteredQuery)
                Console.Write(q + " ");
        }
    }
} //Console output: I Was Here

Polymorphism the C# meaning

Through inheritence a class can be more then one type and this is referred to as polymorphism. Within C# all types are polymorphic, because it treats every type as an Object.

The Microsoft definition is as follows:
“Through inheritance, a class can be used as more than one type; it can be used as its own type, any base types, or any interface type if it implements interfaces. This is called polymorphism. In C#, every type is polymorphic. Types can be used as their own type or as a Object instance, because any type automatically treats Object as a base type.

Polymorphism is important not only to the derived classes, but to the base classes as well. Anyone using the base class could, in fact, be using an object of the derived class that has been cast to the base class type. Designers of a base class can anticipate the aspects of their base class that are likely to change for a derived type. For example, a base class for cars might contain behavior that is subject to change when the car in question is a minivan or a convertible. A base class can mark those class members as virtual, allowing derived classes representing convertibles and minivans to override that behavior.”

The basic “meaning” by the above statement is all C# types are derived from System.Object which allows them to be “morphed” into any type.