C # Object-oriented 3

Source: Internet
Author: User

1. Static members are accessed directly.

2. Static can be accessed without instantiation.

3. Static functions can only access static members.

4. Static constructors have no arguments and no access modifiers.

4. Static class equivalent to sealed/

5. Static classes can only define static members or constants.

6. Static classes are used for extensions. Just like your own method.

7. Extension method The first parameter of the This+ class name.

8. Boxing and unpacking the box to the hidden turn.

9. Unboxing instances

int i = 3;
Object Oi = i;
int j = (int) Oi;
Print (j);

int i = 3;
Object Oi = i;

Packing.

11. Custom conversions to your own structure or class definition display or implicit conversions are custom transformations.

12. Implicit conversion syntax public static implicit operator Dog (cat cat);

13. It is the cat that converts the puppy.

15. Show conversion is public static explicit operator Dog (cat cat);

Public static implicit operator Cat (dog dog) {
return new Cat (Dog._name);
}

17. If the class is the dog method is the cat's

As follows

public static implicit operator Cat (dog dog) {
return new Cat (Dog._name);
}

C # Object-oriented 3

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.