Maha

Maha

  • NA
  • 0
  • 328.2k

NP100 Why is casting not needed

May 10 2008 5:21 PM

Hi Guys

 

NP100 Why is casting not needed

 

In the below program if ie.Current is written in the Console.WriteLine() method casting is not necessary.   

 

Anyone knows please explain the reason.

 

Thank you

 

using System;

using System.Collections;

 

class MainClass

{

    static void Main()

    {

        int[] intArray = { 10, 11, 12, 13 };

 

        IEnumerator ie = intArray.GetEnumerator();

 

        while (ie.MoveNext() == true)

        {

            //int i = (int)ie.Current;

            //Console.WriteLine("{0}", i);

            Console.WriteLine("{0}", ie.Current);

        }

    }

}

/*

10

11

12

13

*/


Answers (2)