System.Xml.NameTable Class

Assembly: System.Xml.dll
Namespace: System.Xml
Summary
Implements a single-threaded XmlNameTable.
C# Syntax:
public class NameTable : XmlNameTable
Remarks
Several classes, such as XmlDocument and XmlReader 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 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 ' atomizedstrings '.

Example
The following example compares two element names.
    //Create the reader.
    XmlTextReader rdr = new XmlTextReader("book.xml");

    NameTable nt = new NameTable();
    String name = nt.Add("book");

    while (rdr.Read()){}
    if (rdr.NameTable.Get("book") == name)
      Console.WriteLine("matches!");

    
See also:
System.Xml Namespace

System.Xml.NameTable Member List:

Public Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the NameTable class.
Public Methods
Add Overloaded:
Add(string key)

Overridden:
Atomizes the specified string and adds it to the NameTable. For more information on atomized strings, see NameTable.
Add Overloaded:
Add(char[] key, int start, int len)

Overridden:
Atomizes the specified string and adds it to the NameTable. For more information on atomized strings, see NameTable.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
Get Overloaded:
Get(string value)

Overridden:
Gets the atomized string with the specified value. For more information on atomized strings, see NameTable.
Get Overloaded:
Get(char[] key, int start, int len)

Overridden:
Gets the atomized string containing the same characters as the specified range of characters in the given array. For more information on atomized strings, see NameTable.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Xml.NameTable Member Details

ctor #1
Summary
Initializes a new instance of the NameTable class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public NameTable();
Remarks
Constructs an empty NameTable.

Return to top


Overloaded Method: Add(
   string key
)
Summary
Atomizes the specified string and adds it to the NameTable.

For more information on atomized strings, see NameTable.

C# Syntax:
public override string Add(
   string key
);
Parameters:

key

The string to add.

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

Return to top


Overloaded Method: Add(
   char[] key,
   int start,
   int len
)
Summary
Atomizes the specified string and adds it to the NameTable.

For more information on atomized strings, see NameTable.

C# Syntax:
public override string Add(
   char[] key,
   int start,
   int len
);
Parameters:

key

The character array containing the string to add.

start

The zero-based index into the array specifying the first character of the string.

len

The number of characters in the string.

Return Value:
The atomized string or the existing string if one already exists in the NameTable. If len is zero, String.Empty is returned.
Exceptions
Exception Type Condition
IndexOutOfRangeException If 0 > start >= key.Length or 0 > len >= key.Length - len.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~NameTable();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: Get(
   string value
)
Summary
Gets the atomized string with the specified value.

For more information on atomized strings, see NameTable.

C# Syntax:
public override string Get(
   string value
);
Parameters:

value

The name to find.

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

Return to top


Overloaded Method: Get(
   char[] key,
   int start,
   int len
)
Summary
Gets the atomized string containing the same characters as the specified range of characters in the given array.

For more information on atomized strings, see NameTable.

C# Syntax:
public override string Get(
   char[] key,
   int start,
   int len
);
Parameters:

key

The character array containing the name to find.

start

The zero-based index into the array specifying the first character of the name.

len

The number of characters in the name.

Return Value:
The atomized string or null if the string has not already been atomized. If len is zero, String.Empty is returned.
Exceptions
Exception Type Condition
IndexOutOfRangeException If 0 > start >= key.Length or 0 > len >= array.Length - start.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.