Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace multithreading
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] numbers = new int[1001];
            for (int i = 0; i < 1000; i++)
            {
                numbers[i] = i;
                Console.WriteLine(numbers);
            }

            Console.ReadKey();

        }
    }
}

this code is not work properly.if i change console.writeline(number) to console.writeline(i)it will work.why?
Posted
Updated 7-Oct-12 22:46pm
v2

Try and put
C#
numbers.ToString();
and then
C#
numbers(i).ToString();
and youll see why.
You could also use String.Join to write out your entire array:
http://msdn.microsoft.com/en-us/library/57a79xd0.aspx[^]
 
Share this answer
 
v2
if adding Console.writeline(numbers[i]) it can work or even if you put console.writeline(i) also it print the number.

because you are using for loop where variable i is holding value, and at the same time you can't access array variable with simply name itself. You also need looping variable inside in it.

I think you got clarification.

Happy coding.
 
Share this answer
 
Because number is the object of int array. its a collection of int type data.
so you write number[i].
 
Share this answer
 
Hi,

you can try the following syntax. May be it help you.

C#
Console.WriteLine(numbers[i]);


Thanks,
Viprat
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900