How to write a method that receives strings array parameter in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = new string[] { "c#", "c++", "java", "python" };

            PrintArray(arr);
        }
        static void PrintArray(string[] arr)
        {
            foreach(string s in arr)
                Console.WriteLine(s);
        }
    }
}


/*
run:
      
c#
c++
java
python

*/

 



answered Dec 28, 2016 by avibootz
...