Mono Class Library: System.String Overview | MembersSystem.String.IsInterned Method |
Retrieves a reference to a specified string. [Edit]
|
A string reference to str if it is in the system's intern pool; otherwise, a null reference. [Edit]
Type Reason ArgumentNullException str is a null reference. [Edit]
Instances of each unique literal string constant declared in a program, as well as any unique instance of string you add programmatically are kept in a table, called the "intern pool".
The intern pool conserves string storage. If a literal string constant is assigned to several variables, each variable is set to reference the same constant in the intern pool instead of referencing several different instances of string that have identical values.
[Edit]
The following example demonstrates the string.IsInterned(string) method.
C# Example using System; using System.Text; public class StringExample { public static void Main() { String s1 = new StringBuilder().Append("My").Append("Test").ToString(); Console.WriteLine(String.IsInterned(s1) != null); } }The output is
True
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0