XmlDictionaryString Class
The XmlDictionaryString
class represents a string that can be added to an XmlDictionary
for efficient XML processing.
Namespace
System.Xml
Assembly
System.Xml.dll
Syntax
public sealed class XmlDictionaryString : IXmlDictionaryString
Base Class
System.Object
Constructors
Constructor | Summary |
---|---|
XmlDictionaryString(XmlDictionary dictionary, string value, int key) |
Initializes a new instance with the specified dictionary, value, and key. |
Properties
Property | Type | Summary |
---|---|---|
Dictionary |
XmlDictionary |
Gets the dictionary that contains this string. |
Key |
int |
Gets the integer key of the string in the dictionary. |
Value |
string |
Gets the string value. |
Methods
Method | Return Type | Summary |
---|---|---|
ToString() |
string |
Returns the string value. |
Equals(object obj) |
bool |
Determines whether the specified object is equal to the current object. |
GetHashCode() |
int |
Gets a hash code for the current object. |
Remarks
An XmlDictionaryString
is used by XmlDictionaryReader
and XmlDictionaryWriter
to improve the performance of XML processing by avoiding repeated string allocations. The Key
provides a fast lookup when the same string appears many times in an XML document.
Example
using System;
using System.Xml;
class Program
{
static void Main()
{
XmlDictionary dict = new XmlDictionary();
XmlDictionaryString hello = dict.Add("Hello");
Console.WriteLine($"Value: {hello.Value}, Key: {hello.Key}");
}
}