Continue in c #

Source: Internet
Author: User

A code continuation

The c # statement uses ";" as the ending symbol, So C # can directly wrap the line without line breaks.

For example:

 

1int a, B = 1, c = 1;
2 a = B
3 +
4 c;

 

Two-string row continuation

Sometimes the string is too long. We want to split it into multiple rows for writing. By default, the string constants in c # Are not sequentially distributed. However, we can use the @ symbol to increase the string's ability to continue rows;

Example:

 

1 string s = @ "<tabl width = '000000'>
2 <tr> <td align = 'left'> dear User: </td> </tr>
3 <tr> <td> & nbsp; Project: {0}, {2} Software Version: {1}. </td> </tr>
4 <tr> <td align = 'right'> OPERATOR: {3} </td> </tr> <td align = 'right'> operation time: {4} </td> </tr>
5 </table>"

 

You may also know that using @ to define a string will ignore the escape characters in the string. What should we do if there are double quotation marks in our string? The following is my solution.

 

1 string s = @"
2 document. getElementById ("" id "")
3 ";
4
5

 

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.