The Count property allows you to get the number of character replacements defined in the dictionary.
To add character replacements to the dictionary, use the AddRange method.
To remove character replacements from the dictionary, the RemoveRange method is used.
The Contains method is used to determine if the dictionary contains a replacement for the specified character.
To get a replacement for the specified character, use the GetReplacement method.
To remove all replacements from the dictionary, use the Clear method.
To export all replacements to a file, use the ExportDictionary method.
To import character replacements from a file, use the ImportDictionary method.
The following example demonstrates the use of the character replacement dictionary methods.
C#
stringindexFolder=@"c:\MyIndex\";// Creating an index from in specified folderIndexindex=newIndex(indexFolder);if(index.Dictionaries.CharacterReplacements.Count>0){// Deleting all character replacements from the dictionaryindex.Dictionaries.CharacterReplacements.Clear();}if(index.Dictionaries.CharacterReplacements.Contains('-')){intreplacement=index.Dictionaries.CharacterReplacements.GetReplacement('-');Console.WriteLine("The replacement for hyphen is "+char.ConvertFromUtf32(replacement));// Deleting the hyphen character replacement from the dictionaryindex.Dictionaries.CharacterReplacements.RemoveRange(newchar[]{'-'});}// Export character replacements to a fileindex.Dictionaries.CharacterReplacements.ExportDictionary(@"C:\CharacterReplacements.dat");// Import character replacements from a fileindex.Dictionaries.CharacterReplacements.ImportDictionary(@"C:\CharacterReplacements.dat");
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: