How to convert one array to another array in C#

1 Answer

0 votes
using System;
using System.Linq;
 
class Program {
    static void Main(string[] args) {
        int[] arr = { 1, 2, 3, 4, 5 };

        var result = from n in arr.ToArray<int>() select n;

        foreach (int n in result)
            Console.Write(n + " ");
    }
}
 
 
 
/*
run:
 
1 2 3 4 5 
 
*/

 



answered Dec 28, 2022 by avibootz

Related questions

1 answer 173 views
1 answer 181 views
4 answers 385 views
1 answer 116 views
...