PROCEDURES AND FUNCTIONS IN .NET LANGUAGES The following code shows the BData class and its constructor and Read()implementation. class BData: ISqlReader, ISqlRecord { // the previous number in the sequence int previous_; // the current number in the sequence int current_; // position in sequence int count_ ; // length of sequence int maxCount_; internal BData(int preStart, int start, int count) { previous_ = preStart; current_ = start; maxCount_ = count; this.count_ = 0; } public bool Read() { // just leave things as they are // for the first time through if (count_ != 0) { // calculate next number in // sequence and remember last int p = current_; current_ += previous_; previous_ = p; } // move to next number in sequence count_ = count_ + 1; if (count_ > maxCount_) { // done with sequence return false; } return true; } } The constructor just saves the first and second numbers in the sequence and the length of the sequence. Each time Read()is called, it just calculates the next number in the sequence. Note that the first time Read() is called, it does not do a calculation; it just leaves the initial values in place. SQL Server will keep on calling Read()to get a row until Read()returns false.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.