C # Generic programming?

Source: Internet
Author: User
In summary, generics have the following two advantages over non-generics:

1. More secure

In non-generic programming, although everything can be passed as an object, type conversion is inevitable during the transfer process. Type conversion is not safe at runtime. Using generic programming can reduce unnecessary type conversion and improve security.

2. Higher efficiency

In non-generic programming, passing a simple type as an object will cause boxing and unboxing operations, both of which are very open-ended. With generic programming, you do not need to perform boxing and unboxing operations.

 

. Net generics have good binary reusability. This is because. Net has built generics into CLR. In C ++ generics and evaluation, Java generics rely on the features provided by their respective compilers.CodeExpand the exact type, which will inevitably lead to code expansion problems. The. NET generic code is compiled by JIT at runtime, so that CLR can reuse most of the real-time compilation code for different types.

Original article address

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.