System.Collections.DictionaryEntry Structure

Assembly: Mscorlib.dll
Namespace: System.Collections
Summary
Defines a dictionary key-and-value pair that can be set or retrieved.
C# Syntax:
[Serializable]
public struct DictionaryEntry
Thread Safety
Public static (non-instance) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
Remarks
The IDictionaryEnumerator.Entry method returns an instance of this class.

The foreach statement of the C# language (for each) requires the type of each element in the collection. Since each element of a collection based on IDictionary is a key-and-value pair, the element type is not the type of the key or the type of the value. Instead, the element type is DictionaryEntry. For example: foreach (DictionaryEntry myEntry in myHashtable) {...}

See also:
System.Collections Namespace | IDictionary | IDictionaryEnumerator

System.Collections.DictionaryEntry Member List:

Public Constructors
ctor #1 Initializes an instance of the DictionaryEntry class with the specified key and value.
Public Properties
Key Read-write

Gets or sets the key in the key-and-value pair.
Value Read-write

Gets or sets the value in the key-and-value pair.
Public Methods
Equals
(inherited from System.ValueType)
See base class member description: System.ValueType.Equals


Indicates whether this instance and a specified object are equal.
GetHashCode
(inherited from System.ValueType)
See base class member description: System.ValueType.GetHashCode


Returns the hash code for this instance.
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.ValueType)
See base class member description: System.ValueType.ToString


Returns the fully qualified type name of this instance.
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.Collections.DictionaryEntry Member Details

ctor #1
Summary
Initializes an instance of the DictionaryEntry class with the specified key and value.
C# Syntax:
public DictionaryEntry(
   object key,
   object value
);
Parameters:

key

The object defined in each key-and-value pair.

value

The definition associated with key.

Exceptions
Exception Type Condition
ArgumentNullException key is null.

Return to top


Property: Key (read-write)
Summary
Gets or sets the key in the key-and-value pair.
C# Syntax:
public object Key {get; set;}

Return to top


Property: Value (read-write)
Summary
Gets or sets the value in the key-and-value pair.
C# Syntax:
public object Value {get; set;}

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.ValueType.Equals

Summary
Indicates whether this instance and a specified object are equal.
C# Syntax:
public override bool Equals(
   object obj
);
Parameters:

obj

Another object to compare to.

Return Value:
true if obj and this instance are the same type and represent the same value; otherwise, false.

Return to top


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

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

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.ValueType.GetHashCode

Summary
Returns the hash code for this instance.
C# Syntax:
public override int GetHashCode();
Return Value:
A 32-bit signed integer that is the hash code for this instance.
Remarks
The ValueType.GetHashCode method applies to types derived from ValueType. One or more fields of the derived type is used to calculate the return value. If one or more of those fields contains a mutable value, the return value might be unpredictable, and unsuitable for use as a key in a hash table.

For more information, see Object.GetHashCode, and Hashtable.

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.ValueType.ToString

Summary
Returns the fully qualified type name of this instance.
C# Syntax:
public override string ToString();
Return Value:
A String containing a fully qualified type name.

Return to top


Top of page

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