

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print the contents of array horizontally using C#?
Set an array.
int[] array = new int[] { 50, 100, 150, 200, 250, 300, 350, 400 };
Now, if you will print this array using a loop and new line, then the arrays will be visible vertically.
To work it horizontally, use the Join() method and set spaces to separate array elements.
string.Join(" ", array)
Let us see the complete code.
Example
using System; using System.Linq; using System.IO; class Program { static void Main() { int[] array = new int[] { 50, 100, 150, 200, 250, 300, 350, 400 }; Console.WriteLine(string.Join(" ", array)); } }
Output
50 100 150 200 250 300 350 400
- Related Questions & Answers
- How to print out the contents of a vector in C++?
- Print contents of a file in C
- Operator overloading in C++ to print contents of vector, map, pair ..
- How to print the Y-axis label horizontally in a Matplotlib/Pylab chart?
- How to print the range of numbers using C language?
- Shuffle Array Contents
- How to read the contents of a JSON file using Java?
- How to print dimensions of multidimensional array in C++
- How to flip an Ellipse horizontally using FabricJS?
- How to flip a Circle horizontally using FabricJS?
- How to delete all the file contents using PowerShell?
- How to Copy the entire contents of a directory in C#?
- How to list the subfolder contents using Get-ChildItem using PowerShell?
- How to store the contents of arrays in a file using Java?
- How to update the contents of a ResultSet using a JDBC program?
Advertisements