
The in keyword is a reserved keyword. This means that in the C# language no variable identifier can ever be "in". In this article, we show the usage of "in" in a foreach-loop.
ForeachThis C# page shows the use of the in keyword. In is part of the foreach-loop.
Using the keyword "in" is very simple. You use it inside the parenthetical expression in the foreach-loop. It comes after the iteration variable declaration and before the object you are iterating across.
Program that shows foreach-loop and in [C#]
using System;
class Program
{
static void Main()
{
int[] array = { 1, 2, 4 };
foreach (int value in array)
{
Console.WriteLine(value);
}
}
}
LINQ. In a LINQ query expression, you can use the "in" keyword as well. This usage of "in" is contextual as with most keywords in query expressions. For more examples of "in" in this context, look at the LINQ section.
System.Linq
There are 77 reserved keywords in the C# programming language and "in" is one of them. They cannot be used as variable identifiers. They are the essential words that C# programs are composed with. Some are more fascinating than others.
Keywords Loop Constructs