Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

String.IsInterned Method

Retrieves a reference to a specified String.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

static member IsInterned : 
        str:string -> string

Parameters

str
Type: System.String

The string to search for in the intern pool.

Return Value

Type: System.String
A reference to str if it is in the common language runtime intern pool; otherwise, a null reference (Nothing in Visual Basic).

ExceptionCondition
ArgumentNullException

str is a null reference (Nothing in Visual Basic).

The common language runtime automatically maintains a table, called the intern pool, which contains a single instance of each unique literal string constant declared in a program, as well as any unique instance of String you add programmatically by calling the Intern method.

The intern pool conserves string storage. If you assign a literal string constant 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.

This method looks up str in the intern pool. If str has already been interned, a reference to that instance is returned; otherwise, a null reference (Nothing in Visual Basic) is returned.

Compare this method to the Intern method.

This method does not return a Boolean value. If you call the method because you want a Boolean value that indicates whether a particular string is interned, you can use code such as the following.

No code example is currently available or this language may not be supported.
NoteNote

Starting with the .NET Framework version 2.0, you can override the use of the intern pool when you use the Ngen.exe (Native Image Generator) to install an assembly to the native image cache on a local computer. For more information, see Performance Considerations in the Remarks section for the Intern property.

The following example demonstrates that literal strings are interned automatically by the compiler.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft