Is String Interned : String « String « C# / CSharp Tutorial






using System;
using System.Text;

  class Class1
  {
    [STAThread]
    static void Main(string[] args)
    {
      string sLiteral = "Automatically Interned";
            string sNotInterned = "Not " + sLiteral;

            TestInterned( sLiteral );
            TestInterned( sNotInterned );

            String.Intern( sNotInterned );
            TestInterned( sNotInterned );

            string string1 = "";
            String string2 = "";

            string1 = "asdf";
            string2 = "asdf1";
            
    }
        
        static void TestInterned( string str )
        {
            if( String.IsInterned( str ) != null )
            {
                Console.WriteLine( "The string \"{0}\" is interned.", str );
            }
            else
            {
                Console.WriteLine( "The string \"{0}\" is not interned.", str );
            }
        }
  }








5.1.String
5.1.1.Declaration of string
5.1.2.String is object
5.1.3.String are immutable
5.1.4.Empty string
5.1.5.Display all the characters in myString using a for loop
5.1.6.Use Indexer to reference chars in a string
5.1.7.Use the Compare() method to compare strings
5.1.8.Use the Concat() method to concatenate strings
5.1.9.Use the addition operator (+) to concatenate strings
5.1.10.Use the Copy() method to copy a string
5.1.11.Use the Equals() method and equality operator to check if two strings are equal
5.1.12.Use the Format() method to format a string
5.1.13.Use the Join() method to join strings
5.1.14.Use the Split() method to split strings
5.1.15.Use the IndexOfAny() and LastIndexOfAny() methods to search for character arrays in a string
5.1.16.Use the Insert(), Remove(), and Replace() methods to modify strings
5.1.17.Use the PadLeft() and PadRight() methods to align strings
5.1.18.Use the Trim(), TrimStart(), and TrimEnd() methods to trim strings
5.1.19.Use the Substring() method to retrieve substrings
5.1.20.Working with Strings
5.1.21.Error; string Is Immutable
5.1.22.Basic String functionality
5.1.23.Is String Interned
5.1.24.Demonstrates the String.Normalize method and the String.IsNormalized method
5.1.25.Whether a string is successfully normalized to various normalization forms.