Class and Object

Source: Internet
Author: User
Process-oriented Program The main difference between design and object-oriented programming is the appearance of classes. A class is just a module that contains both public and private methods and data. A class is unique. A class can have multiple instances, and each instance contains different data. These instances are usually called objects. We will see examples of a single instance and multiple instances later.

Constructor:All classes have special constructors that are called when a class instance is created. The constructor name is always the same as the class name. For example:
Public class form1
{
Public form1 () // Constructor
{
Initializecomponent ();
}
}

if you need to add other initialization Code for the class, you usually compile a private init method and call it after the initializecomponent method.
public class form1
{< br> Public form1 () // constructor
{< br> initializecomponent ();
Init ();
}< br> private void Init ()
{< br> X = 12.5f; // set initial value of X
}< BR >}

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.