Learn C # in a week (Foreword Contra)

zhaozj2021-02-16  49

Search C # (Foreword Renewal 2) C # Talent Bird (QQ: 249178521)

8. Operator

Operator type

- * /% (more) arithmetic

&& ||!?: Logic

<=>> = Relationship

==! = Equal

= Assignment

9. Programming style

· More regular programming style

W plus a space in every side of a binary operator

W In every comma instead of adding a space

W, add a space after each keyword

w one line of statement

Do not have spaces before the W semicolon

W function's garden brackets and parameters do not add spaces

W does not add space between one dollar operator and operand

Add a space with each side of a binary operator:

Console.writeLine ("{0}", result / 13); // Recommended

Console.writeLine ("{0}", result / 13); // Not recommended

In every comma instead of adding a space:

Console.writeLine ("{0}", result / 13); // Recommended

Console.writeLine ("{0}", result / 13); // Not recommended

Each keyword is added to a space:

IF (OneELINE (Comment) ... // Recommended

IF (OneELINE (Comment) ... // Not recommended

Don't have spaces before the semicolon:

Console.writeLine ("{0}", result / 13); // Recommended

Console.writeLine ("{0}", result / 13); // Not recommended

The garden bracket and parameters of the function are not spaced:

IF (OneELINE (Comment) ... // Recommended

IF (OneELINE (Comment) ... // Not recommended

No spaces between one dollar operator and operand:

keywordcount; // recommended

keywordcount; // is not recommended

10. Find the wrong

Bool checked;

... 1

Public static void main ()

{ ... } 2

INT matched = symbol.match (input)

IF (Match> 0)

{

....

} 3

CHAR OPTIONAL = "?"

String theory = 'complex'; 4

INT matched = 0_OR_MORE (Symbol);

... 5

The error of paragraph 1: Checked is a keyword

The error in paragraph 2: Not main, but main

Paragraph 3: Variable declaration statement has no semicolon

The error of paragraph 4: The character value must be represented by single quotes, and the string must use dual quotation to indicate the error error: the first error is that the identifier cannot be started with the number; the second error cannot be used underline Identifier.

转载请注明原文地址:https://www.9cbs.com/read-22171.html

New Post(0)