老外编的程序(九):Using Indexer Properties
// 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; } inWord = -1; } } else { if (isLetter) inWord = i; } } return false; } 上一篇:续(这个例子是针对ACCESS的更新、删除、还有定位的,希望能对你有所帮助) 下一篇:Passport 你的网站(在你的WebSite上实现MS Passport )上 更多相关文章
|
推荐文章
精彩文章
|