locked
What does this statement (object) mean? RRS feed

  • Question

  • See below snippet of C# program. I know how to use 'Current' in statement "public ExtractInfo Current" well, but I don't understand the other statement "object global::System.Collections.IEnumerator.Current". What does it mean? How to use it at upper applications which use this class?

    public sealed class ExtractInfoArrayEnumerator : global::System.Collections.IEnumerator
        , global::System.Collections.Generic.IEnumerator<ExtractInfo>
      {
        private ExtractInfoArray collectionRef;
        .....

        public ExtractInfoArrayEnumerator(ExtractInfoArray collection) {
          collectionRef = collection;
          ...
        }

        // Type-safe iterator Current
        public ExtractInfo Current {
          get {
            if (currentIndex == -1)
              throw new global::System.InvalidOperationException("Enumeration not started.");
            ....
            return (ExtractInfo)currentObject;
          }
        }

        // Type-unsafe IEnumerator.Current
        object global::System.Collections.IEnumerator.Current {
          get {
            return Current;
          }
        }

    ...

    }

    Monday, September 28, 2020 9:12 AM

All replies

  • Without having the classes code at hands, it looks at the first glance like the singleton pattern.


    Monday, September 28, 2020 9:47 AM