If you can manipulate one of the arrays, you can resize it before performing the copy:
T[] array1 = getOneArray(); T[] array2 = getAnotherArray(); int array1OriginalLength = array1.Length; Array.Resize<T>(ref array1, array1OriginalLength + array2.Length); Array.Copy(array2, 0, array1, array1OriginalLength, array2.Length);
Otherwise, you can make a new array
T[] array1 = getOneArray(); T[] array2 = getAnotherArray(); T[] newArray = new T[array1.Length + array2.Length]; Array.Copy(array1, newArray, array1.Length); Array.Copy(array2, 0, newArray, array1.Length, array2.Length);
More on available Array methods on MSDN.
Related Posts:
- Reading CSV file and storing values into an array
- Remove element of a regular array
- How to convert UTF-8 byte[] to string
- How do I concatenate two arrays in C#?
- .Net 4.8 Support for Windows 10 ends in 26 days?
- What is a NullReferenceException, and how do I fix it?
- How do I get a random YouTube video with the YouTube API?
- How can I convert String to Int?
- What is a NullReferenceException, and how do I fix it?
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- Error : Index was outside the bounds of the array.
- No connection could be made because the target machine actively refused it?
- Could not load file or assembly or one of its dependencies
- What does a lock statement do under the hood?
- Could not load file or assembly or one of its dependencies
- All possible array initialization syntaxes
- C# equivalent of C++ map
- How to convert byte array to string [duplicate]
- What is the purpose of nameof?
- How to open .dll files to see what is written inside?
- How to convert byte array to string
- Windows .NET API / Windows 7 / Bluetooth communication with Intel Curie Arduino / Genuino 101
- Error 1053 the service did not respond to the start or control request in a timely fashion
- Get current folder path
- foreach vs someList.ForEach(){}
- Access to the path is denied
- What does mscorlib stand for?
- Extension methods must be defined in a non-generic static class
- Metadata file ‘.dll’ could not be found
- “Error while trying to run project: Unable to start program”. Can run program only once. Then VS needs restart
- Add new item in existing array in c#.net
- How to resolve this System.IO.FileNotFoundException
- What is clr.dll on .Net framework and what does it do?
- Associating enums with strings in C#
- How do I declare a DefaultValue attribute whose value is an array of strings?
- How to resolve this System.IO.FileNotFoundException
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- Extension methods must be defined in a non-generic static class
- Adding values to a C# array
- Adding values to a C# array
- How can I get the application’s path in a .NET console application?
- Reading settings from app.config or web.config in .NET
- How do I create a Shared Code project (.shproj)
- Invalid URI: The format of the URI could not be determined
- Multiple file-extensions searchPattern for System.IO.Directory.GetFiles
- Unable to read data from the transport connection : An existing connection was forcibly closed by the remote host
- How to make an HTTP POST web request
- How to add comments into a Xaml file in WPF?
- Why did I get the compile error “Use of unassigned local variable”?
- The remote server returned an error: (407) Proxy Authentication Required
- How to open a new form from another form
- How do you sort a dictionary by value?
- EntityType has no key defined error
- Deep cloning objects
- Regular expression “^[a-zA-Z]” or “[^a-zA-Z]”
- How do I restart my C# WinForm Application?
- .NET graph library around?
- How to split() a delimited string to a List
- Best way to reverse a string
- An object reference is required to access a non-static member
- Task vs Thread differences
- C# syntax to initialize custom class/objects through constructor params in array?
- How can I know if a process is running?
- String was not recognized as a valid DateTime ” format dd/MM/yyyy”
- XmlSerializer – There was an error reflecting type
- Run Command Prompt Commands
- windows could not start service on local computer error 5 access is denied
- Visual Studio keeps crashing
- How can I implement static methods on an interface?
- Catch multiple exceptions at once?
- How to delete a file after checking whether it exists
- c# Show Windows Form
- How do I exit a WPF application programmatically?
- .NET String.Format() to add commas in thousands place for a number
- Produce a random number in a range using C#
- How to play a sound in C#, .NET
- Which passwordchar shows a black dot (•) in a winforms textbox?
- What is a quick way to force CRLF in C# / .NET?
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- How to resolve file being used by another process?
- How to enable assembly bind failure logging (Fusion) in .NET
- How to make inline functions in C#
- c# .net change label text
- How to create a new object instance from a Type
- Best way to “push” into C# array
- How to avoid a System.Runtime.InteropServices.COMException?
- Using FolderBrowserDialog in WPF application
- Is there an equivalent to the C# “var” keyword in C++/CLI?
- When should I use a List vs a LinkedList
- How can I generate random alphanumeric strings?
- How do you do a deep copy of an object in .NET?
- .NET Core vs Mono
- Iif equivalent in C#
- Convert an array to string
- LINQ query on a DataTable
- Key Value Pair List
- Unrecognized escape sequence for path string containing backslashes
- Linq: GroupBy, Sum and Count
- How to enumerate an enum