How to copy part of array of strings to other array in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main()
        {
            string[] arr = { "c#", "vb.net", "java", "php", "python" };
            string[] arr_copy = new string[arr.Length - 2];

            Array.Copy(arr, arr_copy, arr.Length - 2);

            foreach (string element in arr_copy)
                Console.WriteLine(element);
        }
    }
}


/*
run:
   
c#
vb.net
java
    
*/

 



answered Oct 17, 2018 by avibootz

Related questions

1 answer 275 views
1 answer 222 views
1 answer 241 views
1 answer 211 views
1 answer 346 views
1 answer 299 views
...