Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to print array of any type in C#

6 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intarray = new int[] { 1, 2, 3, 4, 5 };

            Console.WriteLine(String.Join(" ", intarray)); 
        }
    }
}


/*
run:

1 2 3 4 5

*/

 





answered Jul 30, 2018 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] stringarray = new string[] { "c#", "vb.net", "c", "java"};

            Console.WriteLine(String.Join(" ", stringarray)); 
        }
    }
}


/*
run:

c# vb.net c java

*/

 





answered Jul 30, 2018 by avibootz
0 votes
using System;
using System.Collections.Generic;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] stringarray = new string[] { "c#", "vb.net", "c", "java"};

            PrintArray(stringarray);
        }
        static public void PrintArray<T>(IEnumerable<T> arr)
        {
            foreach (var item in arr)
                Console.WriteLine(item); 
        }
    }
}


/*
run:

c#
vb.net
c
java

*/

 





answered Jul 30, 2018 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intarray = new int[] { 1, 2, 3, 4, 5 };

            foreach (var item in intarray) {
                Console.WriteLine(item.ToString());
            }
        }
    }
}


/*
run:

1
2
3
4
5

*/

 





answered Jul 30, 2018 by avibootz
0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intarray = new int[] { 1, 2, 3, 4, 5 };

            intarray.ToList().ForEach(i => Console.WriteLine(i.ToString()));
        }
    }
}


/*
run:

1
2
3
4
5

*/

 





answered Jul 30, 2018 by avibootz
0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intarray = new int[] { 1, 2, 3, 4, 5 };

            intarray.ToList().ForEach(Console.WriteLine);
        }
    }
}


/*
run:

1
2
3
4
5

*/

 





answered Jul 30, 2018 by avibootz

Related questions

2 answers 146 views
1 answer 70 views
1 answer 85 views
1 answer 63 views
...