using
System;
class
Program {
static
void
cpymethod()
{
string
str1 =
"GeeksforGeeks"
;
string
str2 =
"GFG"
;
Console.WriteLine(
"Original Strings are str1 = "
+
"'{0}' and str2='{1}'"
, str1, str2);
Console.WriteLine(
""
);
Console.WriteLine(
"After Copy method"
);
Console.WriteLine(
""
);
str2 = String.Copy(str1);
Console.WriteLine(
"Strings are str1 = "
+
"'{0}' and str2='{1}'"
, str1, str2);
Console.WriteLine(
"ReferenceEquals: {0}"
,
Object.ReferenceEquals(str1, str2));
Console.WriteLine(
"Equals: {0}"
, Object.Equals(str1, str2));
Console.WriteLine(
""
);
Console.WriteLine(
"After Assignment"
);
Console.WriteLine(
""
);
str2 = str1;
Console.WriteLine(
"Strings are str1 = '{0}' "
+
"and str2 = '{1}'"
, str1, str2);
Console.WriteLine(
"ReferenceEquals: {0}"
,
Object.ReferenceEquals(str1, str2));
Console.WriteLine(
"Equals: {0}"
, Object.Equals(str1, str2));
}
public
static
void
Main()
{
cpymethod();
}
}