. Net basic statements

Source: Internet
Author: User

Branch statement

    • Ternary Operators
(......)? B: c
      • Value Method when the value may be null
(S = NULL )? "": S;
    • If else statement
If (){}
Else if (){}
Else {}
    • Switch statement
switch (VAR)
{
case :...... Break;
default :...... Break;
}

Iteration statement

    • Do/WHILE LOOP
Do
{......}
While (<Test> );
    • While Loop
While (<Test>)
{......}
    • For Loop
For (<initialization >;< condition >;< operation>)
{......}
    • Foreach, in Loop
Foreach (<basetype> <Name> in <array>)
{......}

jump statement

    • Break
Terminate cycle now
    • Continue
End the current cycle and enter the next cycle
    • Goto
Jump out of loop to mark position
Goto <labelname>;
<Labelname>:
    • Return
jump out of the loop and end the method containing it

exception BLOCK statement

    • Throw

The throw statement is used to issueProgramAbnormal (abnormal) signal during execution.

    • Try-catch

A try-catch statement consists of a try block followed by one or more catch clauses. These clauses specify different exception handlers, specify catch {...} for general exception handling {......}.

    • try-finally

the Finally block is used to clear any resources allocated in the try block, and run any Code that must be executed even when an exception occurs. The control is always passed to the Finally block, regardless of the exit mode of the try block.

    • Try-catch-finally

A common method used by catch and finally is to obtain and use resources in the try block, handle exceptions in the Catch Block, and release resources in the Finally block.

overflow check statement

    • Checked
Test whether the value type overflows during arithmetic operations. If the overflow occurs, the system. overflowexception exception is obtained.
Try
{
Checked {......}
}
Catch (overflowexception ex)
{
......
}
    • Unchecked
Disable the detection of some codes and ignore overflow exceptions in arithmetic operations
Unchecked
{......}

 

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.