Thursday 23 August 2012

String Clone() in C#

Example on String Clone() Method.


The C# String Clone() method creates and returns a copy of string object. This methode returns a reference to this instance of string.


public class StringCloneExample
      {
            public static void Main()
            {
                  string Str = "Clone Methode Testing";
                  string StrCloned = null;
                  StrCloned = (String)Str.Clone();
                  Console.WriteLine(StrCloned);
                  Console.ReadLine();
            }
      }

1 comment:

  1. check here difference between clone and copy mthod

    Clone will copy the structure of a data where as Copy will copy the complete structure as well as data.

    http://net-informations.com/faq/framework/clone-copy.htm

    maaki

    ReplyDelete