What is generic programming?

Source: Internet
Author: User
Generic is the most powerful function of C #2.0. You can define a type-safe data structure through the generic type without using the actual data type.
This can significantly improve performance and get higher qualityCodeBecause you can reuse Data ProcessingAlgorithmWithout copying specific types of code.
In terms of concept, generics are similar to C ++ templates, but there are significant differences in implementation and functions. This article discusses the problem space of generic processing,
Their implementation methods, the benefits of the programming model, and unique innovations (such as constraints, general methods and delegation, and general inheritance ).
Generic programming allows you to write fully generalized and reusable algorithms, with the same efficiency as the algorithms designed for a specific data type. STL, a representative of generic programming, is an efficient, generic, and interactive software component.
The so-called genericity refers to the meaning that can be operated on multiple data types, which is similar to the template. STL is huge and scalable. It contains many basic computer algorithms and data structures, and completely separates algorithms from data structures,
The algorithm is generic and is not associated with any specific data structure or object type. STL is a generic Algorithm Library Based on iterators and containers. The existence of containers makes these algorithms available for operation.
STL contains various generic algorithms (algorithms), generic pointers (iterators), generic containers (containers), and function objects (function objects ). STL is not just a collection of useful components,
It is a formal and structured architecture that describes the abstract requirements of software components.
The first advantage of generics is strict type check during compilation. This is the most important feature of a collection framework. In addition, generics eliminate the vast majority of type conversions. If there is no generic type, you have to perform type conversion when using the collection framework.
To understand generics, we can sum up the following sentence: data type is passed as a parameter.

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.