Some basic knowledge commonly used in one of C # 's Basic articles

Source: Internet
Author: User

switch (expression)

{

case constant Expression 1: statement 1;break;

Case constant Expression 2: statement 2;break;

......

case constant Expression N: statement n;break;

Default: Statement n+1;break;

}

for (expression; expression 2; expression 3)

loop body statement;

Break statement: Interrupts the currently executing loop and jumps out of the loop.

Continue statement: Ignores the statement after continue and goes to the next loop.

The Nforeach statement is used to enumerate each element in the collection and to manipulate each element by executing a loop body. The n syntax is as follows:

foreach (data-type variable in set expression)

{

statement block;

}

Random number: Random r = new Random ();

int M=r.next (1, 100);

The concept of a class

A class is an abstract concept.

Used to describe a set of objects that have the same characteristics (data members) and the same behavior (function members)

Public: Any code can access private: Only members within the class (default) protected: The class and the derived class of the class in which it resides

Internal: In assembly

Method

A method is a member function that displays the behavior of a class or object, with the following syntax: [access modifier] Returns a value type method name ([parameter])

{

Method body

}

public int ADDXY (int x,int y) {return x+y;

}

Classification of methods

Instance method: Default Stuclass stu=new stuclass (); Stu. instance method (); n static method: Q is declared with Static, belongs to a class and cannot be associated with an instance. Call: Class. static method ();

Static methods can only invoke static members.

Some basic knowledge commonly used in one of C # 's Basic articles

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.