public int SerializeDocuments() { var i = 0; while (reader.MoveNext()) { var text = reader.CurrentText(); var document = new Document(text, i, reader.CurrentName()); documents.Add(document); i++; } return(i); // return number of documents }