Keep for loop controlling variable to its own scope - CSharp Language Basics

CSharp examples for Language Basics:for

Description

Keep for loop controlling variable to its own scope

Demo Code

using System;/* w  w w .  j  a v  a 2  s  . com*/
class Scope
{
   public static void Main()
   {
      for( int x = 1; x < 5; x++ )
      {
         Console.WriteLine("x is {0}", x);
      }

      for( int x = 1; x < 5; x++ )
      {
         Console.WriteLine("x is {0}", x);
      }
   }
}

Result


Related Tutorials