Use foreach to read records

Source: Internet
Author: User
The foreach statement structure in C # is used for read-only and sequential traversal of all elements in a set. The set must implement the system. Collections. ienumerable interface. The foreach statement can simplify the traversal of a set. CodeThe code looks fresh and concise. The foreach statement is derived from the VB for each statement.
To quickly access the database, we generally use the system. Data. idatareader interface to access data. This interface provides read-only and sequential access query results. The two are both "read-only and sequential" features, narrowing the relationship between the two. For this reason, the younger brother is in the system. data. the idatareader interface sets an implementation system. collections. the shell of the ienumerable interface, so that we can use foreach to read the query results. This can avoid generating a large number of struct objects and save memory. The younger brother made a demonstration. ProgramIt is very simple. There are no more than 100 rows. I hope you can use them. It is a command line program and uses demomdb. MDB in the program directory as the demo database. Program http://files.cnblogs.com/xdesigner/foreach_record.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.