Prints the elements of the array next to each other - CSharp System

CSharp examples for System:Array Element

Description

Prints the elements of the array next to each other

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from   w  w w.j  a v a  2  s. co  m*/

public class Main{
        /// <summary>
        /// Prints the elements of the array next to each other
        /// </summary>
        /// <param name="array">The array we want to print</param>
        public static void PrintArray(int[] array)
        {
            foreach (int el in array)
            {
                Console.Write(el + " ");
            }
            Console.WriteLine();
        }
        public static void PrintArray(int[][] array)
        {
            foreach (int[] row in array)
            {
                PrintArray(row);
            }
        }
}

Related Tutorials