My second program-explain the program execution sequence

Source: Internet
Author: User

I,

1. the console Program created by default has only one Program. cs, as well as Properties and references,

 

2. We define a new class. Another. cs

The Code is as follows:

Code
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;

Namespace TestInt
{
Public class Another
{
Public void GetName ()
{
Console. WriteLine ("Hello, My name is Another ");
}
}
}

Here, we only define the Another class, but we haven't started to use it yet.

3. Use the Another class.

Go back to Program. cs and add the content.

Code
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;

// The namespace name can be changed.
Namespace TestInt
{
// This class is created by default.
Class Program
{
Static void Main (string [] args)
{
// Instantiate an Another class. The instantiated variable is objAnother.
// It can also be understood as follows: Another is a "class", and objAnother is an "object" of the class (a "Replica" or "instance ").
// "Class", "object", and "instance" are all nouns. It is okay to know this meaning.
Another objAnother = new Another ();

// We can "instantiate" more Another objects
Another objAnother1 = new Another ();
Another objAnother2 = new Another ();

// Obtain the name:
ObjAnother. GetName ();
// Output: Hello, My name is Another

Console. ReadLine (); // stop the output screen for a while. Wait until you press any key and close it.
}
}
}

Press F5 to run,

Expected result:

 

OK, it's over

Ii. Use debugging to check the execution sequence:

1. Place a breakpoint for the Another class

2. Place a class in Program. cs:

3. Press F5, for example:

4. Press F10,

Press F10.

 

OK, my story is over.

 

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.