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.

Amit Gupta said:   1 decade ago
Why not first is right?

Neeraj said:   1 decade ago
Mark is right. Because in s2=s1 giving the reference of s1 to s2.

Vishnu said:   1 decade ago
String s1 = "String";
String s2;
s2 = s1;
//it is also right

Mark said:   1 decade ago
String s1 = "String";
String s2;
s2 = String.Copy(s1);
//is the right answer!!


Post your comments here:

Your comments will be displayed after verification.