Structural bodies in C #

Source: Internet
Author: User

Structural body

The format of the struct:

Struct variable name

{

Public type variable name ;

}

If the struct is defined in the main function, it can only be used in the main function, the general structure is defined before the main function, all the places inside the main function can be used, and the parameters are preceded by public to represent the common variables

Usage:

Used in the main function: X1 i= new X1 (); Defines a struct of type x1 named I

Assignment: struct name + dot + struct body inside variable name = value;

i.a=12;

structure body Structure body:

Struct x1

{

public int A;

Public X2 Z; The declaration of a X2 type of z,x2 is another type of struct we define.

}

struct X2//This is the definition of a struct named X2

{

public string S;

}

How to use Structure body assignment: x1 i = new X1 ();

I. Z. s = "Hello!" ";

Structural bodies in C #

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.