I have this struct contained within a
public class Class1<TKey1> : IDictionary<TKey1, Class2>
{
#region Private Fields
private Dictionary<Key, Class2> _class2Manager = new Dictionary<Key, Class2>(new KeyEqualityComparer());
#endregion
#region Key
protected internal struct Key
{
private TKey1 _TKeyValue1;
public TKey1 TKeyValue
{
get { return _TKeyValue1; }
set { _TKeyValue1 = value; }
}
public Key(TKey1 keyValue)
{
_TKeyValue1 = keyValue;
}
///Other Key Code
}
#endregion
///Other Class1 Code
}
I am trying to emulate (implement) the dictionary functionality of my _class2Manager
dictionary within class1
. The trouble arises when I want to implement the GetEnumerator()
method. I am not exactly sure how to convert the IEnumerator<KeyValuePair<Key, Class2>>
object returned by the _class2Manager.GetEnumerator()
into a IEnumerator<KeyValuePair<TKey1, Class2>>
IEnumerator<KeyValuePair<TKey1, Class2>> IEnumerable<KeyValuePair<TKey1, Class2>>.GetEnumerator()
{
IEnumerator<KeyValuePair<Key, Class2>> K = _class2Manager.GetEnumerator();
}
How do I convert IEnumerator<KeyValuePair<Key, Class2>>
to IEnumerator<KeyValuePair<TKey1, Class2>>
?
I've thought of casting, but I don't think that is the exact thing I need to do to convert it properly.
Any suggestions are appreciated, thanks.