KeyValue<T,U>
Overview
Represents a key/value pair. This class is used by the Dictionary<T,U> to represent stored data.
Use case
An instance of KeyValue<T,U> is returned by the dictionary when enumerating through values:
var Users := new Dictionary<Integer, String>;
Users.Add(1, "First");
Users.Add(2, "Second");
Users.Add(3, "Third");
Users.ForEach(item -> writeLn(Sugar.String.Format("Id: {0} Name: {1}", item.Key, item.Value)));
Output:
Id: 1 Name: First
Id: 2 Name: Second
Id: 3 Name: Third
Location
- Reference: Sugar
- Namespace: Sugar.Collections
- Ancestry: KeyValuePair<T,U> | KeyValue<T,U>
constructor
Creates a new instance of the class with specified parameters.
constructor(aKey: T; aValue: U)KeyValue<T,U>(T aKey, U aValue)init( aKey: T, aValue: U)KeyValue<T,U>(T aKey, U aValue)Sub New(aKey As T, aValue As U)Parameters:
- aKey: Object that represents a key in pair.
- aValue: Object that represents a value in pair.
Equals (declared in KeyValuePair<T,U>)
method Equals(Obj: Object): BooleanBoolean Equals(Object Obj)func Equals(_ Obj: Object) -> BooleanBoolean Equals(Object Obj)Function Equals(Obj As Object) As BooleanParameters:
- Obj:
GetHashCode (declared in KeyValuePair<T,U>)
method GetHashCode: Int32Int32 GetHashCode()func GetHashCode() -> Int32Int32 GetHashCode()Function GetHashCode() As Int32GetTuple (declared in KeyValuePair<T,U>)
method GetTuple: tuple of (T, U)(T, U) GetTuple()func GetTuple() -> tuple of (T, U)Tuple2<T, U> GetTuple()Function GetTuple() As Tuple (Of T, U)Key (declared in KeyValuePair<T,U>)
property Key: T read;T Key { get; }var Key: T { get{} }T Key { __get; }ReadOnly Property Key() As TToString (declared in KeyValuePair<T,U>)
method ToString: StringString ToString()func ToString() -> StringString ToString()Function ToString() As StringValue (declared in KeyValuePair<T,U>)
property Value: U read;U Value { get; }var Value: U { get{} }U Value { __get; }ReadOnly Property Value() As U
Key (declared in KeyValuePair<T,U>)
property Key: T read;T Key { get; }var Key: T { get{} }T Key { __get; }ReadOnly Property Key() As TValue (declared in KeyValuePair<T,U>)
property Value: U read;U Value { get; }var Value: U { get{} }U Value { __get; }ReadOnly Property Value() As U
constructor
Creates a new instance of the class with specified parameters.
constructor(aKey: T; aValue: U)KeyValue<T,U>(T aKey, U aValue)init( aKey: T, aValue: U)KeyValue<T,U>(T aKey, U aValue)Sub New(aKey As T, aValue As U)Parameters:
- aKey: Object that represents a key in pair.
- aValue: Object that represents a value in pair.
Equals (declared in KeyValuePair<T,U>)
method Equals(Obj: Object): BooleanBoolean Equals(Object Obj)func Equals(_ Obj: Object) -> BooleanBoolean Equals(Object Obj)Function Equals(Obj As Object) As BooleanParameters:
- Obj:
GetHashCode (declared in KeyValuePair<T,U>)
method GetHashCode: Int32Int32 GetHashCode()func GetHashCode() -> Int32Int32 GetHashCode()Function GetHashCode() As Int32GetTuple (declared in KeyValuePair<T,U>)
method GetTuple: tuple of (T, U)(T, U) GetTuple()func GetTuple() -> tuple of (T, U)Tuple2<T, U> GetTuple()Function GetTuple() As Tuple (Of T, U)ToString (declared in KeyValuePair<T,U>)
method ToString: StringString ToString()func ToString() -> StringString ToString()Function ToString() As String