"Go" writing high-quality Code 157 recommendations for improving C # Programs--Recommendation 97: Prioritize the delivery of base types or interfaces as parameters

Source: Internet
Author: User

Recommendation 97: Prioritize the delivery of a base type or interface as a parameter

In addition to the disclosure and type or interface, the parameters of the method should also take into account the base type or interface.

In the case of the enumerable type, the IEnumerable generic interface is used in its member methods whenever it involves the need to manipulate the collection object, such as:

 Public Static Ienumerable<tsource> take<tsource> (thisint  count) {    if  Null)    {        throw error.argumentnull ("source" ) );    }     return Takeiterator<tsource>(source, count);}

This method is used to get a subset of the specified number of collections. That's because of the way this extension exists. We can take operations on all generic collections.

Turn from: 157 recommendations for writing high-quality code to improve C # programs Minjia

Go to write high-quality Code 157 recommendations for improving C # Programs--Recommendation 97: Prioritize the delivery of base types or interfaces as parameters

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.