Created
June 9, 2011 12:13
-
-
Save vaclavbohac/1016619 to your computer and use it in GitHub Desktop.
Example v C# string interning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
// Example of C# string interning. | |
// Created by Vaclav Bohac in 2011 | |
class Test | |
{ | |
public static void Main() | |
{ | |
string foo = "Lipsum", | |
bar = "Lipsum"; | |
string buz = new StringBuilder().Append("Li").Append("psum").ToString(); | |
Console.WriteLine((Object) foo == (Object) bar); // True | |
Console.WriteLine((Object) foo == (Object) buz); // False | |
// ... but ... | |
Console.WriteLine(foo == buz); // True | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment