Total Page Views :- webs counters

Introduction

Suppose we have two following arrays with different length:-

int[] data = new int[5] { 3, 4, 5, 6, 9 };
int[] marks = { 4, 5, 6 };

		

Now create third array in which you want to store the result of merging array.

int[] final = new int[data.Length + marks.Length];

		

CopyTo() Function

Now start copying these arrays in final in the following manner:-

data.CopyTo(final, 0);
marks.CopyTo(final, data.Length);

		

We use CopyTo function in which we pass the destination array and starting index from where you want to start copying.

Traversal of Merged Array

Now traverse the final array and you will get result.

foreach (int x in final)
        {

            Response.Write(x + ",");
        
        }


		

Email Address

For any query you can send mail at info@techaltum.com
Thanks