المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : VB to C# conversion. Implements



C# Programming
12-22-2009, 03:20 PM
I am converting a class from VB to C# so that it can be compiled into the same assembly, but have run into something that I don't know how to handle. The class is a generic ObservableDictionary. My problem is that I don't know how to implement both System.Collections.Generic.IEnumerable.GetEnumerator and System.Collections.IEnumerable.GetEnumerator since both of them need an exposed function named GetEnumerator().

The VB code is as follows:

Public Function GetEnumerator()
As System.Collections.Generic.IEnumerator(
Of System.Collections.Generic.KeyValuePair(Of TKey, TValue))
Implements System.Collections.Generic.IEnumerable(
Of System.Collections.Generic.KeyValuePair(Of TKey, TValue)).GetEnumerator

Return DirectCast(Dictionary, IDictionary).GetEnumerator()
End Function

Private Function GetEnumerator1()
As System.Collections.IEnumerator
Implements System.Collections.IEnumerable.GetEnumerator

Return GetEnumerator()
End Function


It looks to me like the VB code is renaming the GetEnumerator function to GetEnumerator1 and explicitly mapping this back to the GetEnumerator function that is being implemented, but I have never seen anything like this in C#.

Is this possible in C#?