locked
Code will not work RRS feed

  • Question

  • Code:

    for(int i=x;i>-1;i--){

    Console.WriteLine("{0}", name[x]);

    }// for

    this code will not work, what am I doing wrong?

    Friday, March 23, 2007 10:17 PM

Answers

  • your code looks fine... what error are you getting?

    Did you initialize x?

    Do you want to change:
    Console.WriteLine("{0}", name[x]);
    to...
    Console.WriteLine("{0}", name[ i ]);
    ?

    Otherwise, it will print name[x] for i to 1 times.


    Probably need a few more details
    Friday, March 23, 2007 10:43 PM

All replies

  • You'll need to provide more detail. What do you mean by "this code will not work"? Do you mean that it does not compile, or that it does not output what you expect it to? A more complete code example, including the declaration of "name", might also be helpful.

    -Tom Meschter
    Software Dev, Visual C# IDE

    Friday, March 23, 2007 10:32 PM
  • your code looks fine... what error are you getting?

    Did you initialize x?

    Do you want to change:
    Console.WriteLine("{0}", name[x]);
    to...
    Console.WriteLine("{0}", name[ i ]);
    ?

    Otherwise, it will print name[x] for i to 1 times.


    Probably need a few more details
    Friday, March 23, 2007 10:43 PM