3.7.txt
来自「《Microsoft Visual C# .NET 2003开发技巧大全》源代码」· 文本 代码 · 共 35 行
TXT
35 行
Listing 3.7 Interning a String by Using the Intern Method
using System;
namespace _7_StringBuilder
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string sLiteral = “Automatically Interned”;
string sNotInterned = “Not “ + sLiteral;
TestInterned( sLiteral );
TestInterned( sNotInterned );
String.Intern( sNotInterned );
TestInterned( sNotInterned );
}
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 );
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?