C # Network application programming classes, constructors, methods, properties, and fields

Source: Internet
Author: User

1. Class
Definition form: Public (private) class (Class) Apple (class name)
Note: Public does not restrict access to private access limited to this class

2. Constructors

Definition form: is a special method. public class name (parameter table) {}
Function: used primarily to initialize an object when an object is created, that is, to assign an initial value to an object member variable.
is always used with the new operator in the statement of the wearing object.

2. Methods
Definition form: public void (method type defined) Send (method name) (parameter)
{


}
Note: The method can be static or non-static. Access to static methods through the class, through the tired
Instance (object) to access an instance method.

3. Properties and Fields
Property: Property provides access to the attributes of an object or class. A property is a natural extension of a field.
The syntax for accessing properties and fields is the same.
The difference between a property and a field: Unlike a field, a property does not represent a storage location. Property
Has accessors that specify statements that execute when their values are read or written.

The form of the field: private string name;
Form of property: public string Name
{
Get{retrun Name;}
Set{name=value}

}
Note: Properties do not have the ability to store data, and the data is stored in fields, so only the modified field's
Data to change the data, modifying the value of the property is not used.

C # Network application programming classes, constructors, methods, properties, and fields

Related Article

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.