The XmlNameTable is an abstract base class with NameTable as an implementation. The NameTable contains atomized versions of element and attribute names, along with namespace URIs and prefixes. If the application is doing a lot of comparisons on element or attribute names, the application should use the NameTable from the XmlReader. The user can get the NameTable that the reader is using from the XmlReader..::.NameTable property. For a description of atomization, see XmlNameTable.
The application can add names to the table with the Add method. The following example shows that comparisons are then done by using the Equals method or == operator, which determines whether the object given in the method call is the same instance as the current object.
Dim cust As Object = reader.NameTable.Add("Customer")
While reader.Read()
' The "if" uses efficient pointer comparison.
If cust Is reader.Name Then
...
End If
End While
object cust = reader.NameTable.Add("Customer");
while (reader.Read())
{
// The "if" uses efficient pointer comparison.
if (cust == reader.Name)
{
...
}
}