В VS 2017 у нас есть реализация KeyValuePair, такая как
namespace System.Collections.Generic
{
//
// Summary:
// Defines a key/value pair that can be set or retrieved.
//
// Type parameters:
// TKey:
// The type of the key.
//
// TValue:
// The type of the value.
public struct KeyValuePair<TKey, TValue>
{
//
// Summary:
// Initializes a new instance of the System.Collections.Generic.KeyValuePair`2 structure
// with the specified key and value.
//
// Parameters:
// key:
// The object defined in each key/value pair.
//
// value:
// The definition associated with key.
public KeyValuePair(TKey key, TValue value);
//
// Summary:
// Gets the key in the key/value pair.
//
// Returns:
// A TKey that is the key of the System.Collections.Generic.KeyValuePair`2.
public TKey Key { get; }
//
// Summary:
// Gets the value in the key/value pair.
//
// Returns:
// A TValue that is the value of the System.Collections.Generic.KeyValuePair`2.
public TValue Value { get; }
//
// Summary:
// Returns a string representation of the System.Collections.Generic.KeyValuePair`2,
// using the string representations of the key and value.
//
// Returns:
// A string representation of the System.Collections.Generic.KeyValuePair`2, which
// includes the string representations of the key and value.
public override string ToString();
}
}
Я хотел бы реализовать свою собственную KeyValuePair с другим именем.Мой код
namespace IEnumerableTest1
{
public struct ParameterNameValuePair<TParameterName, TValue>
{
public ParameterNameValuePair(TParameterName parameterName, TValue value);
public TParameterName ParameterName { get; }
public TValue Value { get; }
public override string ToString();
}
}
Теперь у меня есть ошибка в коде:
Ошибка CS0501 'ParameterNameValuePair.ParameterNameValuePair (TParameterName, TValue)' должен объявить тело, поскольку оно не помечено как абстрактное, extern или частичное IEnumerableTest1
Ошибка CS0501 'ParameterNameValuePair.ToString ()' должно объявлять тело, поскольку оно не помечено как абстрактное, внешнее или частичное IEnumerableTest1
Как решить вышепроблемы?