Lucas_Santos
Lucas_Santos

Reputation: 4740

Iterator Pattern pass through parameter

How can I pass through parameter a variable that is my Iterator ?

protected void LeXMLNode(FileUpload fupArquivo)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(fupArquivo.FileContent);

            XmlNodeList ndo = doc.SelectNodes("*");

            var it = ndo.GetEnumerator();
            using (it as IDisposable)
            while (it.MoveNext())
            {                
                //// Pass the variable it as parameter
            }
        }

Upvotes: 0

Views: 511

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 416039

Use the .Current property:

using (var it = ndo.GetEnumerator())
    while (it.MoveNext())
    {                
        //// Pass the variable it as parameter
        SomeFunction(it.Current);
    }

Upvotes: 1

Related Questions