C # Notes (14)--Interface generics

Source: Internet
Author: User
interface with generics 1. Definition of interface: Access modifier Interface Interface Name {Member}2. The interface is an abstract of the year, with the aim of subclasses implementing it 3. Interfaces are typically used to define a uniform standard between different classes 4. Interface members: Including methods, properties, events, indexes, Cannot have field 5. Interface members cannot have modifiers, default is public and require implementation class (subclass) to implement all interface members in the interface 6. Interfaces and abstract classes are abstract concepts, so objects cannot be created (not new) 7. If a class implements multiple interfaces, the interface is separated by a comma "," 8 If a class inherits one parent class at a time and implements one or more interfaces, the parent class is placed at the front of the generic method: public void Method Name < type > () {} generic class:test<int> A = new test<int> (); Constraints for generic parameters: public class Test<t>where T:struct {} can only be of value type: public class Test<t>where T:class {} can only be of reference type

C # Notes (14)--Interface generics

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.