C # knowledge Summary

Source: Internet
Author: User

1. How do I distinguish between overload methods?

Different parameter types, different parameter numbers, and different parameter order

2. C # use a variety of modifiers to express the different properties of the class. According to the class of its protection level C #, there are five different restrictions and modifiers. What are the differences between them?

A:

Public can be accessed at will

Protected can only be accessed by this class and its inherited subclass

Internal can only be accessed by all classes in the Assembly. The combination is the logical unit and physical unit after the classes in C # language are combined, the compiled file extension is often ". DLL or. EXE ".

Protected internal is a unique composite modifier that can only be accessed by all classes in the current composite and the inherited sub-classes of these classes.

Private can only be accessed by this class.

3. What is the difference between interfaces and abstract classes?

A: interfaces are used for standardization and abstract classes are used for commonality. The interface can only declare methods, attributes, events, and indexers. Abstract classes can be implemented using methods or non-static class variables. Abstract classes are classes, so they can only be inherited by a single object, but multiple interfaces can be implemented at a time. An abstract class can provide partial implementation of some methods, and an interface cannot. An instance of an abstract class is provided by its subclass. An interface instance is provided by the class that implements the interface. When a method is added to an abstract class, its subclass has this method at the same time. When a new method is added to an interface, the class implementing it must be rewritten (that is why the interface is a Class Specification ). Interface members are defined as public, however, abstract class members can also be private, protected, internal, or protected internal members (the protected internal members can only be accessed in the application code or derived classes). In addition, the interface cannot contain fields, constructors, destructor, static members, or constants.

4. What is an abstract class?

Answer: an abstract class contains one or more abstract methods. It cannot be instantiated.

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.