Recent

Author Topic: IEnumerator interface Current property, GetCurrent function  (Read 1933 times)

Pasqualish

  • Jr. Member
  • **
  • Posts: 68
In using the TStringsEnumerator it appears that enumerator.GetCurrent and enumerator.Current return the same thing. I see that the IEnumerator interface defines both a GetCurrent function and a Current property and says that Current is "simply is the redefinition of IEnumerator.GetCurrent as a property. It is read-only."  I am wondering why they have both. My guess would be that the enumerator interface was in existence before properties and initially only had the GetCurrent function.

The other thing is that the IEnumerator returns TObject for GetCurrent and Current, while TStringsEnumerator returns string for both. Seems like that makes it harder for someone using an interface if it can be implemented with different return types.
« Last Edit: July 26, 2016, 12:04:14 pm by Pasqualish »

 

TinyPortal © 2005-2018