バージョン

KeyLowercaseInterned プロパティ (IKeyedSubObjectEx)

文字列のインターンされた小文字バージョンを返します (読み取り専用)。
シンタックス
'宣言
 
ReadOnly Property KeyLowercaseInterned As String
string KeyLowercaseInterned {get;}
解説

返された文字列を使用して、大文字小文字を識別しない比較を最適化します。

使用例
Private KeyValue As String = ""
Private KeyInternedValue As String = ""
Private KeyLowercaseInternedValue As String = ""

Public ReadOnly Property KeyLowercaseInterned() As String Implements Infragistics.Shared.IKeyedSubObjectEx.KeyLowercaseInterned

    Get
        If Me.KeyValue.Length = 0 Then Return Me.KeyValue

        ' If the string hasn't changed since the last internment
        ' then return the cached value
        If Object.ReferenceEquals(Me.KeyValue, Me.KeyInternedValue) = True Then
            If Not Me.KeyLowercaseInternedValue Is Nothing Then
                Return Me.KeyLowercaseInternedValue
            End If
        End If

        ' Intern the key and save the interned string reference
        Me.KeyInternedValue = String.Intern(Me.KeyValue)

        ' Intern the string converted to lowercase so we can do case
        ' insensitive compares
        Me.KeyLowercaseInternedValue = String.Intern(Me.KeyInternedValue.ToLower())

        Return Me.KeyLowercaseInternedValue

    End Get

End Property
private string keyInterned;
private string keyLowercaseInterned;
private string key = "";

string IKeyedSubObjectEx.KeyLowercaseInterned
{

	get 
	{
		string key = this.key;
		
		if ( key == null || key.Length == 0 )
			return key;
		
		// If the string hasn't changed since the last internment
		// then return the cached value
		if ( object.ReferenceEquals( key, this.keyInterned ) )
		{
			if ( this.keyLowercaseInterned != null )
				return this.keyLowercaseInterned;
		}
		
		// Intern the key and save the interned string reference
		//
		this.keyInterned = string.Intern( key );
		
		// Intern the string converted to lowercase so we can do case
		// insensitive compares
		//
		this.keyLowercaseInterned = string.Intern( this.keyInterned.ToLower() );
		
		return this.keyLowercaseInterned;
	}

}
参照