csharp print array
Code Example - csharp print array
string[] myArray = {"Dogs", "Cats", "Birds"};
foreach (string item in myArray)
{
Console.WriteLine(item);
}
print array in csharp
Console.WriteLine(string.Join("\n", myArrayOfObjects));
print content of array csharp
//array of numbers, it works with strings also
int numbers[3] = {1, 4, 5, 6}
/*declares int named 'number' and assigns it the value of an index
starting from index 0 to the end of the array, in this case, 3*/
foreach(int number in numbers){
//prints the number
Console.WriteLine(number);
}
csharp console writeline array
Console.WriteLine("{0}", string.Join(", ", arryElement));
csharp string console readline array
string foo = Console.ReadLine();
string[] tokens = foo.Split(",");
List<int> nums = new List<int>();
int oneNum;
foreach(string s in tokens)
{
if(Int32.TryParse(s, out oneNum))
nums.Add(oneNum);
}
csharp print array one line
//Displaying an array in one line
int[] numbers = new int[4];
foreach(int display in numbers)
{
Write(display+",");
}