Expectations for the future of C,

Source: Internet
Author: User

Expectations for the future of C,

A year of contact with C # is generally a perfect language, but some detailed features are still not perfect. Write down some of my future expectations.

The more powerful generic constraints are similar to the C ++ template. The C # Generic constraints make it easier to write code suitable for multiple types. If there is no generic type, we may need to use the object and perform type conversion, or write a lot of identical code for each type. In terms of generic type constraints, C # Is as strict as ever, but due to the imperfect generic constraints, sometimes I have to write some repeated code. For example, in the following example: public static T Max <T> (T a, T B) where T is int or long or float or double {return a> = B? A: B;} Unfortunately, C # does not yet have this function... System. Math is used to write a Max Method for various types. For more information about C # Generic constraints, see constraints on type parameters. Differences between templates and generics: differences between C ++ templates and C # generics. Namespace range access modifier C # provides an internal access modifier to protect internal types or members of the Assembly. However, in actual development, we often need to drag sub-modules in a program. In order to clearly distinguish the public content of classes in the same submodule from the public content of different submodules, we hope that C # can provide access modification to the namespace range in the future. For example, in the following example: copy the code namespace Moudle {public class Common {...} private class Secret {...}} copy the code to add access modification of the private type, so that the Common can access the Secret. The Secret type is visible in the Moudle namespace and invisible outside the Moudle. Note that the current C # does not allow the namespace element to be declared as private or protected. Youyuan in C ++ can solve this problem, but I guess you do not like friend... Using Internal classes can solve this problem to a certain extent, but it is not free. This problem is even more serious in Unity development because the script component must be written in a separate file and cannot be considered an internal class.

Related Article

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.