Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

Intern

static func Intern(text: string) -> string

Declaring type: String
Module: System
Assembly: System.Runtime.dll
Source file: String.rvn

Returns the canonical reference for exact text within the current execution.

Parameters

Name Type Description
text String Non-null text to intern.

Return value

String

The existing canonical String, or the supplied String when its contents are first added.

Remarks

Development API. The pool strongly retains unique text until execution completes, faults or is cancelled. Host-held results remain valid afterward. Independent host invocations and isolated workers have separate pools; supplying an already shared String can still preserve its identity across invocations. Existing references are not rewritten: use the returned value. Matching uses exact UTF-8 contents without normalization or case folding. Empty text and embedded NUL are supported. No literal interning or lookup helper is provided. A null String default raises NullReference. Rust hosts configure Limits.intern_entries and Limits.intern_bytes; defaults are 4096 distinct entries and 1 MiB of unique UTF-8 payload. New entries exceeding either limit raise terminal InternPoolLimitExceeded; existing hits remain available at capacity. Limits exclude table/owner/allocator overhead and input allocations. This differs from the CLR's longer-lived pool.