The role of Out parameters in C #

Source: Internet
Author: User

Let me give you a simple explanation. Although not entirely right. But I can make you understand what the effect of out is. Oh
Let me give you an example. Each method can have only one return value. But you want to have multiple return values, huh. Out is working. such as paging, not only to return data, but also to return the total number of records
Such as:
Public DataSet getData (out int count)
{
DataSet Ds=bll.getdata (10,20);
Get 11th to 20th data: But it's not possible to show only a total of 10 records. Oh. Then we're going to use out.
int RCOUNT=BLL. GetCount ();//For example, this is the total number of records taken.
Count=rcount;

return DS;
}

When it is displayed

public void ShowData ()
{
int count=0;

Gridview1.datasource=getdata (out count);
Gridview1.databind ();
label1.text= "Total" +count.tostring () + "records";
}

The role of Out parameters in C #

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.