The break and continue in net and an array of objects

Source: Internet
Author: User
Tags array length

I. The role of break and Continue keywords

1. Break:

1.1 For switch structure, jump out of switch

1.2 For loop structure, end entire loop

2, continue

2.1 Only for loop structure, end this cycle, continue into the next cycle

2.2 This cycle, the code behind the continue does not execute

Second, an array of objects

1, Function: Save data (in the form of objects to encapsulate the different data types of values)

2. Declare an array, allocate the space class name [] Object array name =new class name [array length];

3. Assign Value

Mode 1:

Prepares the element, then declares the array, and saves the element to the array

Class Name Object 1=new class name ();

Object 1. Attribute 1= value 1;

................

Object 1. Attribute n= value N; .... You can create multiple objects and assign values to properties

  

Class Name Object N=new class name ();

Object N. property 1= value 1;

................

Object N. property n= value N;

Class name [] Object array name ={object 1, Object 2 ... Object n};

Mode 2: "Recommended"

Declare the array and assign the length, and then assign the values to the elements in the group

Class name [] Object array name =new class name [length];

* * Object array name [Subscript]=new class name ();

Object array name [subscript]. Attribute 1= value 1;

4. Iterating through an array of objects

foreach (class name Object name in object array name) {

Output Properties

If (object name!=null) {

Console.WriteLine (object name. Attribute name);

}

}

The break and continue in net and an array of objects

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.