Why are the 2 string references the same? I am trying to write a copy constructor and want to avoid string references that point to the same string.
using System;
namespace StringRefTest
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("String Test!");
string s = "f"; // This should be one reference
string t = "f"; // This should be another
if (ReferenceEquals(s, t))
Console.WriteLine("Ref Same");
else
Console.WriteLine("Ref Not Same"); // Should be true
// The references are the same
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}