C# Language in


Example

The in keyword has three uses:

a) As part of the syntax in a foreach statement or as part of the syntax in a LINQ query

foreach (var member in sequence)
{
    // ...
}

b) In the context of generic interfaces and generic delegate types signifies contravariance for the type parameter in question:

public interface IComparer<in T>
{
    // ...
}

c) In the context of LINQ query refers to the collection that is being queried

var query = from x in source select new { x.Name, x.ID, };