मेरे पास एक कक्षा है जो IEnumerator<string>
लागू करती है। तथ्य यह है कि .Current संपत्ति दोनों IEnumerator<T>
इंटरफेस और IEnumerator
इंटरफ़ेस (जो IEnumerator<T>
inherits) पर मौजूद है, यह लागू करने की बात क्या है इसके अलावामुझे आईएन्यूमेरेटर <T> लागू करने वाली कक्षा में IENumerator.Current की आवश्यकता क्यों है?
public class MyClass : IEnumerator<string>
{
public bool MoveNext()
{
//....
}
//Implement other required methods....
//Confusion lies below:
public string Current { get { return this.CurrentLine; } }
//Why do I need to implement IEnumerator.Current?! In my tests, it's not even called during my iteration
object IEnumerator.Current { get { throw new NotImplementedException(); } }
}
: नीचे देखें? जैसा कि ऊपर देखा गया है, इसे भी बुलाया नहीं जाता है।
+1 इस मामले में IENumerator.Current के कार्यान्वयन के तरीके पर एक उदाहरण देने के लिए +1। – contactmatt