C# Programming - Strings - Discussion

Discussion Forum : Strings - General Questions (Q.No. 3)
3.
Which of the following statements will correctly copy the contents of one string into another ?
String s1 = "String";
String s2; 
s2 = s1;
String s1 = "String" ; 
String s2;
s2 = String.Concat(s1, s2);
String s1 = "String"; 
String s2;
s2 = String.Copy(s1);
String s1 = "String"; 
String s2;
s2 = s1.Replace();
String s1 = "String"; 
String s2;
s2 = s2.StringCopy(s1);
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
14 comments Page 2 of 2.

Dheer said:   1 decade ago
String s2, s1 = "string";

s2 = s1;
s2.equals(s1);

Nasser Amira said:   1 decade ago
Awesome discussion. In response to @Nichholas, when you run the following the console return true actually not false.

String s1 = "String";
String s2;
s2 = s1;
Console.Write(object.ReferenceEquals(s1, s2));

Pankaj mehta said:   1 decade ago
Case A one references got copied.

Mean both string now got started to point same [Memory].

Case C exact data is copied in other string.

Naresh said:   9 years ago
Will get same object name.

String s1 = "String";
String s2;
s2 = String.Copy(s1);
Console.WriteLine(s2);
Console.WriteLine(s1);
Console.WriteLine(s1.GetHashCode());
Console.WriteLine(s2.GetHashCode());


Post your comments here:

Your comments will be displayed after verification.