in

suggest change

The in keyword has these uses. C# 7.2 also uses in on a parameter to pass that argument by readonly reference.

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

            foreach (var member in sequence)
            {
                Console.WriteLine(member);
            }
    
  2. On a generic interface or delegate, in signifies contravariance for that type parameter:

    public interface IComparer<in T>
    {
        int Compare(T left, T right);
    }
    
  3. In a LINQ query, in refers to the collection that is being queried

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents