String.IsInterned メソッドとは? わかりやすく解説

String.IsInterned メソッド

指定した String への参照取得します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

strnull 参照 (Visual Basic では Nothing) です。

解説解説
使用例使用例

次のコード例では、リテラル文字列コンパイラによって自動的にインターン プール格納されるようすをデモンストレーションしています。

' Sample for String.IsInterned(String)
Imports System
Imports System.Text

Class Sample
   Public Shared Sub Main()
      ' String str1 is known at compile time, and is automatically interned.
      Dim str1 As [String] = "abcd"
      
      ' Constructed string, str2, is not explicitly or automatically
 interned.
      Dim str2 As [String] = New
 StringBuilder().Append("wx").Append("yz").ToString()
      Console.WriteLine()
      Test(1, str1)
      Test(2, str2)
   End Sub 'Main
   
   Public Shared Sub Test(sequence
 As Integer, str As [String])
      Console.Write("{0}) The string, '",
 sequence)
      Dim strInterned As [String] = [String].IsInterned(str)
      If strInterned Is Nothing
 Then
         Console.WriteLine("{0}', is not interned.", str)
      Else
         Console.WriteLine("{0}', is interned.", strInterned)
      End If
   End Sub 'Test
End Class 'Sample '
'This example produces the following results:
'
'1) The string, 'abcd', is interned.
'2) The string, 'wxyz', is not interned.
'
// Sample for String.IsInterned(String)
using System;
using System.Text;

class Sample {
    public static void Main()
 {
// String str1 is known at compile time, and is automatically interned.
    String str1 = "abcd";

// Constructed string, str2, is not explicitly or automatically interned.
    String str2 = new StringBuilder().Append("wx").Append("yz").ToString();
    Console.WriteLine();
    Test(1, str1);
    Test(2, str2);
    }

    public static void Test(int
 sequence, String str) {
    Console.Write("{0}) The string, '", sequence);
    String strInterned = String.IsInterned(str);
    if (strInterned == null)
        Console.WriteLine("{0}', is not interned.", str);
    else
        Console.WriteLine("{0}', is interned.", strInterned);
    }
}
/*
This example produces the following results:

1) The string, 'abcd', is interned.
2) The string, 'wxyz', is not interned.
*/
// Sample for String::IsInterned(String)
using namespace System;
using namespace System::Text;
void Test( int sequence, String^ str )
{
   Console::Write( "{0} The string '", sequence );
   String^ strInterned = String::IsInterned( str );
   if ( strInterned == nullptr )
      Console::WriteLine( "{0}' is not interned.", str );
   else
      Console::WriteLine( "{0}' is interned.", strInterned );
}

int main()
{
   
   // String str1 is known at compile time, and is automatically interned.
   String^ str1 = "abcd";
   
   // Constructed string, str2, is not explicitly or automatically interned.
   String^ str2 = (gcnew StringBuilder)->Append( "wx" )->Append(
 "yz" )->ToString();
   Console::WriteLine();
   Test( 1, str1 );
   Test( 2, str2 );
}

/*
This example produces the following results:

1) The string 'abcd' is interned.
2) The string 'wxyz' is not interned.
*/
// Sample for String.IsInterned(String)
import System.*;
import System.Text.*;

class Sample
{
    public static void main(String[]
 args)
    {
        // String str1 is known at compile time, and is automatically
 interned.
        String str1 = "abcd";
        // Constructed string, str2, is not explicitly or automatically
 
        // interned.
        String str2 = (new StringBuilder()).Append("wx").Append("yz").
            ToString();
        Console.WriteLine();
        Test(1, str1);
        Test(2, str2);
    } //main

    public static void Test(int
 sequence, String str)
    {
        Console.Write("{0}) The string, '", System.Convert.ToString(sequence));
        String strInterned = String.IsInterned(str);
        if (strInterned == null) {
            Console.WriteLine("{0}', is not interned.", str);
        }
        else {
            Console.WriteLine("{0}', is interned.", strInterned);
        }
    } //Test
} //Sample 
 /*
This example produces the following results:

1) The string, 'abcd', is interned.
2) The string, 'wxyz', is not interned.
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からString.IsInterned メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からString.IsInterned メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からString.IsInterned メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

String.IsInterned メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



String.IsInterned メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS