Information Technology Reference
In-Depth Information
Multiple Expressions in the Initializer and Iterator
Both the initializer and the iterator can contain multiple expressions as long as they are sepa-
rated by commas.
For example, the following code has two variable declarations in the initializer and two
expressions in the iterator:
static void Main( )
{
const int MaxI = 5;
Two declarations Two expressions
for (int i = 0, j = 10; i < MaxI; i++, j += 10)
{
Console.WriteLine("{0}, {1}", i, j);
}
}
The output from this code is the following:
0, 10
1, 20
2, 30
3, 40
4, 50
Search WWH ::




Custom Search