[Mono-bugs] [Bug 79441][Nor] Changed - String.IsInterned doesn't work as expected

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Sep 19 08:34:13 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by kornelpal at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=79441

--- shadow/79441	2006-09-19 08:25:23.000000000 -0400
+++ shadow/79441.tmp.5187	2006-09-19 08:34:13.000000000 -0400
@@ -1,13 +1,13 @@
 Bug#: 79441
 Product: Mono: Runtime
 Version: 1.1
 OS: GNU/Linux [Other]
 OS Details: 
-Status: NEW   
-Resolution: 
+Status: RESOLVED   
+Resolution: NOTABUG
 Severity: Unknown
 Priority: Normal
 Component: misc
 AssignedTo: mono-bugs at ximian.com                            
 ReportedBy: pawel.sakowski at mindbreeze.com               
 QAContact: mono-bugs at ximian.com
@@ -50,6 +50,46 @@
 Additional Information:
 mono 1.1.13.6
 
 ------- Additional Comments From robertj at gmx.net  2006-09-19 08:25 -------
 That's a documentation bug.
 
+
+------- Additional Comments From kornelpal at gmail.com  2006-09-19 08:34 -------
+The property behaves as expected because it informs you that the 
+string is not interned.
+
+Only string literals are interned by default.
+
+Note that MS.NET prints False as well.
+
+If you need a True, use this:
+using System;
+using System.Text;
+
+public class StringExample {
+    public static void Main() {
+
+        String s1 = String.Intern(new StringBuilder().Append
+("My").Append("Test").ToString());
+
+        Console.WriteLine(String.IsInterned(s1) != null);
+    }
+}
+
+Or this:
+using System;
+using System.Text;
+
+public class StringExample {
+    public static void Main() {
+
+        String s1 = new StringBuilder().Append("My").Append
+("Test").ToString();
+	String s2 = "MyTest";
+
+        Console.WriteLine(String.IsInterned(s1) != null);
+	// This is not required I only added to ensure that s2
+	// won't be optimized out.
+	GC.KeepAlive(s2);
+    }
+}


More information about the mono-bugs mailing list