Answer the question
In order to leave comments, you need to log in
I'm trying to merge 3 arrays into one, what should I do?
Program code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Programm
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
string[] files =
string[] convert(object sender, EventArgs e)
{
string[] files1 = Directory.GetFiles($"{Directory.GetCurrentDirectory()}media", "*.jpg", SearchOption.AllDirectories);
string[] files2 = Directory.GetFiles($"{Directory.GetCurrentDirectory()}media", "*.png", SearchOption.AllDirectories);
string[] files3 = Directory.GetFiles($"{Directory.GetCurrentDirectory()}media", "*.jpeg", SearchOption.AllDirectories);
string[] files12 = files1.Concat(files2).ToArray();
string[] files = files12.Concat(files3).ToArray();
return files;
}
Answer the question
In order to leave comments, you need to log in
As an example
string[] convert() {
string[] files = Directory.GetFiles(Environment.CurrentDirectory + @"\media", "*.jpg", SearchOption.AllDirectories);
string[] files2 = Directory.GetFiles(Environment.CurrentDirectory + @"\media", "*.png", SearchOption.AllDirectories);
string[] files3 = Directory.GetFiles(Environment.CurrentDirectory + @"\media", "*.jpeg", SearchOption.AllDirectories);
string[] filesAll = new string[files.Length + files2.Length + files3.Length];
files.CopyTo(filesAll, 0);
files2.CopyTo(filesAll, files.Length);
files3.CopyTo(filesAll, files.Length + files2.Length);
return filesAll;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question