XML System.Xml [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 This class is multi-read threadsafe but not threadsafe for read/write. System.Xml.XmlNameTable

The following example demonstrates the difference between equal string values and equal objects using the class.

`using System; using System.Text; using System.Xml; class Ntable { public static void Main() { NameTable nameTable = new NameTable(); string str1 = "sunny"; StringBuilder strBuilder = new StringBuilder(); string str2 = strBuilder.Append("sun").Append("ny").ToString(); Console.WriteLine( "{0} : {1}", str1, str2 ); Console.WriteLine( "{0} : {1}", str1 == str2, (Object)str1==(Object)str2 ); string str3 = nameTable.Add(str1); string str4 = nameTable.Add(str2); Console.WriteLine( "{0} : {1}", str3, str4 ); Console.WriteLine( "{0} : {1}", str3 == str4, (Object)str3==(Object)str4 ); } }`

The output is

sunny : sunny

True : False

sunny : sunny

True : True

Several classes, such as and , use the NameTable class internally to store attribute and element names. When an element or attribute name occurs multiple times in an XML document, it is stored only once in the NameTable.

The names are stored as common language runtime (CLR) object types. This enables you to do object comparisons on these strings rather than a more expensive string comparison. These string objects are referred to as atomized strings.

Implements a single-threaded .

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  Constructs an empty NameTable.

  Initializes a new instance of the NameTable class.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` is .

  For more information on atomized strings, see .

  Atomizes the specified string and adds it to the NameTable.

  The atomized string or the existing string if it already exists in the NameTable.

  The string to add. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` `` ``

  < 0.

  - or -

  >= .Length.

  - or -

  > .Length - .

  The above conditions do not cause an exception to be thrown if = 0.

  len < 0.

  For more information on atomized strings, see .

  Atomizes the specified string and adds it to the NameTable.

  The atomized string or the existing string if one already exists in the NameTable. If is zero, String.Empty is returned.

  The character array containing the string to add. The zero-based index into the array specifying the first character of the string. The number of characters in the string. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` is .

  For more information on atomized strings, see .

  Gets the atomized string with the specified value.

  The atomized string object or null if the string has not already been atomized.

  The name to find. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` `` ``

  < 0.

  - or -

  >= .Length.

  - or -

  > .Length - .

  The above conditions do not cause an exception to be thrown if = 0.

  len < 0.

  For more information on atomized strings, see .

  Gets the atomized string containing the same characters as the specified range of characters in the given array.

  The atomized string or null if the string has not already been atomized. If is zero, String.Empty is returned.

  The character array containing the name to find. The zero-based index into the array specifying the first character of the name. The number of characters in the name. 0
0