What is the difference between the System.Array.CopyTo() and System.Array.Clone()

Clear Coding :
         


           

            int[] array1 = { 1, 2, 3, 4 };
            int[] array2 = array1;
            array2[2] = 5;
            Console.WriteLine(array1[2]);
            Console.WriteLine(array2[2]);

            Output :
            5
            5

            int[] array1 = { 1, 2, 8, 4 };
            int[] array2 = (int[])array1.Clone();
            int[] array3 = new int[6];
            array1.CopyTo(array3, 2);

            array2[2] = 5;
            array3[3] = 11;

            Console.WriteLine(array1[3]);
            Console.WriteLine(array2[3]);
            Console.WriteLine(array3[1]);
            Output :
            3
            5





           int[] array1 = { 1, 2, 8, 4 };
            int[] array2 = (int[])array1.Clone();
            int[] array3 = new int[6];// Length should be (number of position(2)+array1Length(4))(6)
            array1.CopyTo(array3, 2);

            array2[2] = 5;
            array3[3] = 11;

            Console.WriteLine(array1[3]);
            Console.WriteLine(array2[3]);
            Console.WriteLine(array3[1]);
 

            int[] array1 = { 1, 2, 3, 4 };
            int[] array2 = array1;
            array2[2] = 5;
            Console.WriteLine(array1[2]);
            Console.WriteLine(array2[2]);

            //Output :
            //5
            //5

            int[] array1 = { 1, 2, 3, 4 };
            int[] array2 = (int[])array1.Clone();
            array2[2] = 5;
            Console.WriteLine(array1[2]);
            Console.WriteLine(array2[2]);

            //Output :
            //3
            //5

            int[] array1 = { 1, 2, 8, 4 };
            int[] array2 = (int[])array1.Clone();
            int[] array3 = new int[6];// Length should be (number of position(2)+array1Length(4))(6)
            array1.CopyTo(array3, 2);

            array2[2] = 5;
            array3[3] = 11;

            Console.WriteLine(array1[3]);
            Console.WriteLine(array2[3]);
            Console.WriteLine(array3[1]);

Web Services Clear Example

Following example will give a clear Idea about how to create a Web Service and How to consume the service.


Create One Web Service Application

-->File-->New-->Project-->VC-->Web-->Asp.Net Web Service Application

By default one service will be added "HELLO WORLD"


Think that you are providing this service only.

Then Public this though IIS, then you will get a Link.


Create one Project for Accessing the Web Service.

Add the reference as

Right click on Project select Add Web Service Reference and Give the path of Hosted Web Service
Link.

There you can find the Namespace.

If you want to call the Web Service method then you need to create the instance as

Namespace.ServiceName proxy=new Namespace.ServiceName();
proxy.WebMethod() nothing but a service.