. NET Learning 2nd quarter C # Object oriented

Source: Internet
Author: User

. Net Video Learning 2nd-quarter C # Object-oriented

Object-oriented Beginner

A class is a template that does not account for memory, which is the image generated by the template, which accounts for memory.

Fields field: Data methods method: Function Property: Protect field, limit the assignment of a field (wrap this part in a class, the outside world ignores how) the nature of the property is two methods get ()/set ()

External (and even intra-class methods) are assigned/read by attributes, and get ()/set () is qualified internally, and the field is always private, and the property is public.

namespace proj{    class  person    {        private  int _age;          Public int        Age {
get {return _age;} Set { if0) { value 0; } = value ; }}}

Write-only properties are allowed, and the compiler automatically generates fields corresponding to the attributes.

Create a keyword for a class object (instantiation) New

The keyword in the method that points to the object itself.

Non-static = instance, non-static class can have static members or non-static members

. NET Learning 2nd quarter C # Object oriented

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.