TextElementEnumerator クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public Class TextElementEnumerator Implements IEnumerator
[SerializableAttribute] [ComVisibleAttribute(true)] public class TextElementEnumerator : IEnumerator
[SerializableAttribute] [ComVisibleAttribute(true)] public ref class TextElementEnumerator : IEnumerator

.NET Framework は、単一の文字として表示されるテキストの単位、つまり書記素としてテキスト要素を定義します。テキスト要素は、基本文字、サロゲート ペア、または組み合わせた文字シーケンスの場合があります。Unicode Standard は、サロゲート ペアを 2 つのコード単位から成る単一の抽象文字を表すコード化文字表現として定義します。ペアの最初の単位が上位サロゲート、2 番目の単位が下位サロゲートとなります。Unicode Standard は、組み合わせ文字シーケンスを 1 つの基本文字と 1 つ以上の組み合わせ文字の組み合わせとして定義します。サロゲート ペアは、基本文字または組み合わせた文字を表すことができます。サロゲート ペアおよび組み合わせ文字シーケンスの詳細については、http://www.unicode.org の「The Unicode Standard」を参照してください。
テキスト要素の列挙子は、文字列内のデータを読み取ることだけを目的として使用されます。列挙子は、基になる文字列を変更するためには使用できません。
列挙子は、作成されるときに文字列の現在の状態のスナップショットを取得します。テキスト要素の追加、変更、削除などの変更が文字列に対して実行されると、スナップショットが同期されなくなり、列挙子は InvalidOperationException をスローします。同じ文字列から同時に作成された 2 つの列挙子が、その文字列の異なるスナップショットを持つこともできます。
文字列の最初のテキスト要素の前、または文字列の最後のテキスト要素の後に位置している列挙子は無効な状態です。列挙子が無効な状態の場合に Current を呼び出すと、必ず例外がスローされます。
初期状態では、列挙子は文字列の最初のテキスト要素の前に位置しています。Reset を実行した場合も、列挙子はこの位置に戻されます。したがって、列挙子を作成した後や Reset を呼び出した後に、文字列の最初のテキスト要素に列挙子を進めるためには、Current の値を読み取る前に MoveNext を呼び出す必要があります。
Current は、MoveNext または Reset が呼び出されるまでは同じオブジェクトを返します。
文字列の末尾を過ぎると列挙子が再び無効な状態になるため、MoveNext を呼び出すと false が返されます。MoveNext への最後の呼び出しで false が返された場合に Current を呼び出すと、例外がスローされます。

TextElementEnumerator によって返される値を次のコード例に示します。
Imports System Imports System.Globalization Imports Microsoft.VisualBasic Public Class SamplesTextElementEnumerator Public Shared Sub Main() ' Creates and initializes a String containing the following: ' - a surrogate pair (high surrogate U+D800 and low surrogate U+DC00) ' - a combining character sequence (the Latin small letter "a" followed by the combining grave accent) ' - a base character (the ligature "") Dim myString As String = ChrW(&HD800) & ChrW(&HDC00) & ChrW(&H0061) & ChrW(&H0300) & ChrW(&H00C6) ' Creates and initializes a TextElementEnumerator for myString. Dim myTEE As TextElementEnumerator = StringInfo.GetTextElementEnumerator( myString ) ' Displays the values returned by ElementIndex, Current and GetTextElement. ' Current and GetTextElement return a string containing the entire text element. Console.WriteLine("Index" + ControlChars.Tab + "Current" + ControlChars.Tab + "GetTextElement") myTEE.Reset() While myTEE.MoveNext() Console.WriteLine("[{0}]:" + ControlChars.Tab + "{1}" + ControlChars.Tab + "{2}", myTEE.ElementIndex, myTEE.Current, myTEE.GetTextElement()) End While End Sub 'Main End Class 'SamplesTextElementEnumerator 'This code produces the following output. The question marks take the place of high and low surrogates. ' 'Index Current GetTextElement '[0]: ?? ?? '[2]: a` a` '[4]:
using System; using System.Globalization; public class SamplesTextElementEnumerator { public static void Main() { // Creates and initializes a String containing the following: // - a surrogate pair (high surrogate U+D800 and low surrogate U+DC00) // - a combining character sequence (the Latin small letter "a" followed by the combining grave accent) // - a base character (the ligature "") String myString = "\uD800\uDC00\u0061\u0300\u00C6"; // Creates and initializes a TextElementEnumerator for myString. TextElementEnumerator myTEE = StringInfo.GetTextElementEnumerator( myString ); // Displays the values returned by ElementIndex, Current and GetTextElement. // Current and GetTextElement return a string containing the entire text element. Console.WriteLine( "Index\tCurrent\tGetTextElement" ); myTEE.Reset(); while (myTEE.MoveNext()) { Console.WriteLine( "[{0}]:\t{1}\t{2}", myTEE.ElementIndex, myTEE.Current, myTEE.GetTextElement() ); } } } /* This code produces the following output. The question marks take the place of high and low surrogates. Index Current GetTextElement [0]: ?? ?? [2]: a` a` [4]: */
using namespace System; using namespace System::Globalization; int main() { // Creates and initializes a String containing the following: // - a surrogate pair (high surrogate U+D800 and low surrogate U+DC00) // - a combining character sequence (the Latin small letter S"a" followed by the combining grave accent) // - a base character (the ligature S"") String^ myString = L"\xD800\xDC00" L"a\u0300\u00C6"; // Creates and initializes a TextElementEnumerator for myString. TextElementEnumerator^ myTEE = StringInfo::GetTextElementEnumerator( myString ); // Displays the values returned by ElementIndex, Current and GetTextElement. // Current and GetTextElement return a String* containing the entire text element. Console::WriteLine( "Index\tCurrent\tGetTextElement" ); myTEE->Reset(); while ( myTEE->MoveNext() ) Console::WriteLine( "[{0}]:\t {1}\t {2}", myTEE->ElementIndex, myTEE->Current, myTEE->GetTextElement() ); } /* This code produces the following output. The question marks take the place of high and low surrogates. Index Current GetTextElement [0]: ?? ?? [2]: a` a` [4]: */
import System.*; import System.Globalization.*; public class SamplesTextElementEnumerator { public static void main(String[] args) { // Creates and initializes a String containing the following: // - a surrogate pair (high surrogate U+D800 and low surrogate U+DC00) // - a combining character sequence (the Latin small letter "a" // followed by the combining grave accent) // - a base character (the ligature "") String myString = "\uD800\uDC00\u0061\u0300\u00C6"; // Creates and initializes a TextElementEnumerator for myString. TextElementEnumerator myTEE = StringInfo.GetTextElementEnumerator(myString); // Displays the values returned by ElementIndex, Current and // GetTextElement. // Current and GetTextElement return a string containing the entire // text element. Console.WriteLine("Index\tCurrent\tGetTextElement"); myTEE.Reset(); while(myTEE.MoveNext()) { Console.WriteLine("[{0}]:\t{1}\t{2}", System.Convert.ToString(myTEE.get_ElementIndex()), System.Convert.ToString(myTEE.get_Current()), myTEE.GetTextElement()); } } //main } //SamplesTextElementEnumerator /* This code produces the following output. The question marks take the place of high and low surrogates. Index Current GetTextElement [0]: ?? ?? [2]: a` a` [4]: */

System.Globalization.TextElementEnumerator


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TextElementEnumerator プロパティ
TextElementEnumerator メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetTextElement | 文字列内の現在のテキスト要素を取得します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | MoveNext | 列挙子を文字列の次のテキスト要素に進めます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | Reset | 列挙子を初期位置、つまり文字列の最初のテキスト要素の前に設定します。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

TextElementEnumerator メンバ
TextElementEnumerator データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetTextElement | 文字列内の現在のテキスト要素を取得します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | MoveNext | 列挙子を文字列の次のテキスト要素に進めます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | Reset | 列挙子を初期位置、つまり文字列の最初のテキスト要素の前に設定します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からTextElementEnumeratorを検索する場合は、下記のリンクをクリックしてください。

- TextElementEnumeratorのページへのリンク