Declaring More Than One Local x - CSharp Custom Type

CSharp examples for Custom Type:Method

Description

Declaring More Than One Local x

Demo Code

using System;//from w  w  w  .  jav  a2s.c  om
class MainClass
{
   public static void Main()
   {
      for( int x = 1; x < 5; x++ )
      {
         Console.WriteLine("x is {0}", x);
      }
      // Second for statement trying to redeclare x...
      for( int x = 1; x < 5; x++ )
      {
         Console.WriteLine("x is {0}", x);
      }
   }
}

Result


Related Tutorials