Print out complete array content

Hi all,

I can’t find exactly how to print complete array content using a single command line. Is it possible and how to do it, I tried to dig it up, but unlucky so far.

Can you please help and reveal the command and/or example to do it? Thanks

using System;

namespace DocumentationHunt
  class Program
    static void Main(string[] args)
      string[] summerStrut;
      summerStrut = new string[] { "Juice", "Missing U", "Raspberry Beret", "New York Groove", "Make Me Feel", "Rebel Rebel", "Despacito", "Los Angeles" };
      int[] ratings = { 5, 4, 4, 3, 3, 5, 5, 4 };
      string [] summerStrutCopy = new string [8];
      Array.Copy(summerStrut, summerStrutCopy, 8);
      Array.Clear(ratings, 0, ratings.Length);
// **I've been using summerStrut.Length here, and a few other options, none provides result needed**

The current output is ‘System.String’, the other option gives 8 (number of elements).

I’m able to print out single element value e.g. ‘Console.WriteLine(ratings[3]);’ or ‘Console.WriteLine(ratings[0]);’ (as needed in this excercise).
I’m just curious and couldn’t find examples of how to print the whole stack.

Done, I found it:
foreach (int allRatings in ratings){
This final worked out. Printscreen below:

1 Like