C # Constructors

Source: Internet
Author: User

The most common evaluation of a programmer is that the fundamentals are solid. This sentence itself has been pondering the meaning of it, until the problem of the construction function to realize that their basic knowledge is not solid.

constructor Syntax

A constructor is a method whose name is the same as the name of the type. Its method signature contains only the method name and its argument list, and it does not include the return type. The following example shows a constructor for a class named person.

 Public class person{   privatestring last ;    Private string First ;        Public Person (stringstring  firstName)   {      = lastName;       = firstName;   }       // Remaining implementation of person class.}

Static Constructors

Not many of their own practical applications. Maybe the project manager hasn't reached a certain level yet. What you need to know is an official document that you can read directly to the C # Programming Guide.

For constructors, there is no return type, no return type, no return type (important thing to say three times), not void, because void is also the return type, see MSDN.

Reference: C # Programming Guide

C # Constructors

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.