// indexedproperty.cs
using System;
public class Document
{
    // Type allowing the document to be viewed like an array of words:
    public class wordCollection
    {
        readonly Document document;  // The containing document
        internal wordCollection(Document d)
        {
           document = d;
        }
        // Helper function -- search character array "text", starting at
        // character "begin", for word number "wordCount." Returns false
        // if there are less than wordCount words. Sets "start" and
        // length" to the position and length of the word within text:
        private bool Getword(char[] text, int begin, int wordCount, 
                                       out int start, out int length) 
        { 
            int end = text.Length;
            int count = 0;
            int inword = -1;
            start = length = 0; 
            for (int i = begin; i <= end; ++i) 
            {
                bool isLetter = i < end && Char.IsLetterOrDigit(text[i]);
                if (inword >= 0) 
                {
                    if (!isLetter) 
                    {
                        if (count++ == wordCount) 
                        {
                            start = inword;
                            length = i - inword;
                            return true;
             &