Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to write int array to console c#

You may try this:

foreach(var item in yourArray)
{
  Console.WriteLine(item.ToString());
}
Also you may want to try something like this:
yourArray.ToList().ForEach(i => Console.WriteLine(i.ToString()));

EDIT: to get output in one line [based on your comment]: 

Console.WriteLine("[{0}]", string.Join(", ", yourArray));
//output style:  [8, 1, 8, 8, 4, 8, 6, 8, 8, 8]

EDIT(2019): As it is mentioned in other answers it is better to use Array.
ForEach<T> method and there is no need to do the ToList step.

Array.ForEach(yourArray, Console.WriteLine);
Credit: Hossein Narimani Rad
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity check if other object is colliding 
Csharp :: unity always rotating object 
Csharp :: newtonsoft create dynamic object 
Csharp :: C# decimal with two places store as string with two places 
Csharp :: .net c# print object 
Csharp :: c# string remove 
Csharp :: unity reverse string 
Csharp :: if in dictionary c# 
Csharp :: get last element of array c# 
Csharp :: unity editor dropdown 
Csharp :: c# cast to int 
Csharp :: selection sort in c# 
Csharp :: c# use hashtable check if key exists 
Csharp :: visual studio console clear 
Csharp :: get last character of string c# 
Csharp :: switch case in c# with multiple values 
Csharp :: how to create a delegate in c# 
Csharp :: C# array of repeated value 
Csharp :: wpf mouse over style trigger 
Csharp :: c# regex match 
Csharp :: c# get folder path from file path 
Csharp :: c# best tutorial 
Csharp :: get tree node godot 
Csharp :: xmldocument to c# object 
Csharp :: c# return task list 
Csharp :: get key value from object c# 
Csharp :: c# radio button checked 
Csharp :: c# .net core memory cache 
Csharp :: override gethashcode 
Csharp :: The foreach Loop c# 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =