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

 

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): Boolean

 

Boolean Equals(Object Obj)

 

func Equals(_ Obj: Object) -> Boolean

 

Boolean Equals(Object Obj)

 

Function Equals(Obj As Object) As Boolean

Parameters:

  • Obj:

GetHashCode    (declared in KeyValuePair<T,U>)

 

method GetHashCode: Int32

 

Int32 GetHashCode()

 

func GetHashCode() -> Int32

 

Int32 GetHashCode()

 

Function GetHashCode() As Int32

GetTuple    (declared in KeyValuePair<T,U>)

 

method GetTuple: tuple of (T, U)

 

(T, U) GetTuple()

 

func GetTuple() -> (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 T

ToString    (declared in KeyValuePair<T,U>)

 

method ToString: String

 

String ToString()

 

func ToString() -> String

 

String ToString()

 

Function ToString() As String

Value    (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 T

Value    (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): Boolean

 

Boolean Equals(Object Obj)

 

func Equals(_ Obj: Object) -> Boolean

 

Boolean Equals(Object Obj)

 

Function Equals(Obj As Object) As Boolean

Parameters:

  • Obj:

GetHashCode    (declared in KeyValuePair<T,U>)

 

method GetHashCode: Int32

 

Int32 GetHashCode()

 

func GetHashCode() -> Int32

 

Int32 GetHashCode()

 

Function GetHashCode() As Int32

GetTuple    (declared in KeyValuePair<T,U>)

 

method GetTuple: tuple of (T, U)

 

(T, U) GetTuple()

 

func GetTuple() -> (T, U)

 

Tuple2<T, U> GetTuple()

 

Function GetTuple() As Tuple (Of T, U)

ToString    (declared in KeyValuePair<T,U>)

 

method ToString: String

 

String ToString()

 

func ToString() -> String

 

String ToString()

 

Function ToString() As String