Sdílet prostřednictvím


UnicodeCharacterRangeCollection.Add Method

Adds a new character to the UnicodeCharacterRangeCollection repeated a specified number of times.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

Syntax

'Declaration
Public Function Add ( _
    first As Char, _
    length As Integer _
) As UnicodeCharacterRange
'Usage
Dim instance As UnicodeCharacterRangeCollection 
Dim first As Char 
Dim length As Integer 
Dim returnValue As UnicodeCharacterRange 

returnValue = instance.Add(first, length)
public UnicodeCharacterRange Add(
    char first,
    int length
)
public:
UnicodeCharacterRange^ Add(
    wchar_t first, 
    int length
)
public function Add(
    first : char, 
    length : int
) : UnicodeCharacterRange

Parameters

  • length
    Type: System.Int32

    The number of times added character occurs.

Return Value

Type: Microsoft.Ink.UnicodeCharacterRange
The UnicodeCharacterRange added.

Examples

In this example, a UnicodeCharacterRangeCollection is instantiated and several operations performed upon it.

Dim UCRC As UnicodeCharacterRangeCollection = New UnicodeCharacterRangeCollection()
' add three UnicodeCharacterRange objects
UCRC.Add("A", 26)
UCRC.Add("a", 26)
UCRC.Add("0", 10)
Dim countOfRanges As Integer = UCRC.Count ' 3
' this is true because collection contains the exact range 
Dim thisIsTrue As Boolean = UCRC.Contains(New UnicodeCharacterRange("A", 26))
' this is false because collection does not contain exact range 
Dim thisIsFalse As Boolean = UCRC.Contains(New UnicodeCharacterRange("a", 25))
' does not remove because the exact range: '0', 11 does not exist
UCRC.Remove(New UnicodeCharacterRange("0", 11))
' removes because the exact range '0', 10 does exist
UCRC.Remove(New UnicodeCharacterRange("0", 10))
Dim newCountOfRanges As Integer = UCRC.Count ' 2
' idxOfLowerCase = 1 (2nd range added) 
Dim idxOfLowerCase As Integer = UCRC.IndexOf(New UnicodeCharacterRange("a", 26))
' idxOfDigits = -1 because that range does not exist (it was removed) 
Dim idxOfDigits As Integer = UCRC.IndexOf(New UnicodeCharacterRange("0", 10))
' create an array of UnicodeCharacterRange 
Dim UCRArray(UCRC.Count) As UnicodeCharacterRange
' copy from the collection to the array
UCRC.CopyTo(UCRArray, 0)
UnicodeCharacterRangeCollection UCRC = new UnicodeCharacterRangeCollection();
// add three UnicodeCharacterRange objects
UCRC.Add('A', 26);
UCRC.Add('a', 26);
UCRC.Add('0', 10);
int countOfRanges = UCRC.Count; // 3 
// this true because collection contains the exact range 
bool thisIsTrue = UCRC.Contains(new UnicodeCharacterRange('A', 26));
// this is false because collection does not contain exact range 
bool thisIsFalse = UCRC.Contains(new UnicodeCharacterRange('a', 25));
// does not remove because the exact range: '0', 11 does not exist
UCRC.Remove(new UnicodeCharacterRange('0', 11));
// removes because the exact range '0', 10 does exist
UCRC.Remove(new UnicodeCharacterRange('0', 10));
int newCountOfRanges = UCRC.Count; // 2 
// idxOfLowerCase = 1 (2nd range added) 
int idxOfLowerCase = UCRC.IndexOf(new UnicodeCharacterRange('a', 26));
// idxOfDigits = -1 because that range does not exist (it was removed) 
int idxOfDigits = UCRC.IndexOf(new UnicodeCharacterRange('0', 10));
// create an array of UnicodeCharacterRange
UnicodeCharacterRange[] UCRArray = new UnicodeCharacterRange[UCRC.Count];
// copy from the collection to the array
UCRC.CopyTo(UCRArray, 0);

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

UnicodeCharacterRangeCollection Class

UnicodeCharacterRangeCollection Members

Microsoft.Ink Namespace