variables, operators, expressions

Source: Internet
Author: User

variables, operators, Expressions

1. A statement is a command that can perform an operation. The simplest and most important C # syntax rule: You must use a semicolon to terminate all statements.

2.rules followed by identifiers:

▲ Use only letters, numbers, underscore characters

▲ identifiers must start with a letter or an underscore

3. Keywords and their meanings

Key words

Meaning

Abstract

Identifies a class or method that can be extended but not manifested and must be implemented.

As

A conversion operator that returns NULL if the conversion fails .

Base

Used to access a base class member that is hidden by a member of the same name in a derived class or construct.

bool

A simple type that represents a Boolean value.

Break

A jump statement that is used to exit from a loop or switch statement.

Byte

A simple type that represents an unsigned 8-bit length integer.

Case

Specifies a label in the switch statement. If the constant specified in the label matches the value of the switch expression, the statement associated with the tag is executed.

Catch

Defines a block of code that executes in-block code when a particular type of exception is thrown. Participate in try and finally.

Char

Represents A simple type of a Unicode character.

Checked

is both an operator and a statement. Ensures that the compiler and the runtime check for overflow when integer type operations or conversions occur.

Class

Indicates that a declaration is a declaration of a class type.

Const

Identifies a variable value that can be computed at compile time, that is, a value that cannot be modified once assigned.

Continue

The jump statement to return to the top of the loop.

Decimal

A simple type that represents a high-precision decimal number.

Default

In the switch statement, specify a set of statements that execute if there are no matching case clauses in front of them.

Delegate

Specifies that a declaration is a delegate type. A delegate encapsulates a method as a callable entity and can be called in a delegate entity.

Do

Specifies that a declaration is a delegate type. A delegate encapsulates a method as a callable entity and can be called in a delegate entity.

Double

A simple type that represents a single-digit double-precision floating-point value.

Else

if the condition is not true, then the statement after the else is executed if a part of the IF condition statement .

Enum

Represents a value type for a named constant cluster.

Event

A member that allows a class or object to provide notification, which must be a delegate type.

Explicit

An operator that defines the user-defined conversion operator, which is typically used to convert the built-in type to a user-defined type or to a reverse operation. An explicit conversion operator must be called at conversion time.

extern

Identifies a method that will be implemented externally (usually not in the C # language).

False

A Boolean literal.

Finally

Defines a block of code that executes after program control leaves the try code block. See try and catch keywords.

Fixed

When a block of code executes, a pointer is assigned to a variable at the fixed memory location.

Float

A simple type that represents a single-precision floating-point value.

For

Defines a looping statement that continues as long as the specified condition is satisfied.

Foreach

The elements (Arrays and collection objects) that are used to traverse a cluster.

Goto

A jump statement that redirects the program execution to a label statement.

If

A conditional statement that selects a statement execution based on the value of a Boolean expression.

Implicit

An operator that defines a user-defined conversion operator. Typically used to convert a predefined type to a user-defined type or to a reverse operation. The implicit conversion must be used at the time of conversion.

Inch

A part of the Foreach statement traversal syntax that is placed between the variable name and the cluster to traverse.

Int

Represents a simple type of a four-bit signed integer value.

Interface

Specifies a declaration as an interface type, that is, a contract that implements a class or construct that must be followed.

Internal

An access modifier. Internal code elements can only be accessed by other types within the same assembly. Assemblies can be DLLs or EXE files.

Is

Compares a comparison operator for two object types.

Lock

In a multithreaded program, set a mutex for the variable.

Long

A simple type that represents a four-bit signed integer value.

Namespace

Defines the type and namespace of a logical group.

New

The operator used to invoke the constructor. It is also a modifier used to hide and not overload an inherited method that has the same signature.

Null

Represents a literal value equivalent to 0 in a reference type .

Object

A predefined reference type that represents the ultimate base class for all reference types. is also an alias for the predefined type System.Object.

operator

Used to declare or load one operator.

Out

Identifies a parameter that is affected by a parameter value, but does not need to be initialized before passing in the method.

Override

A modifier that indicates that a method will override a virtual method or abstract method, or that an operator will override the same name operator defined in the base class.

Params

Declares an array of arguments. If used, the last parameter specified must be modified. Optional parameters are allowed.

Private

An access modifier. A private member can only be accessed within the type that defines the member.

Protected

An access modifier. A protected member can be accessed only in the type or derived type that defines the member.

Public

An access modifier. A public member can freely access inside and outside the class or namespace in which the member is defined.

ReadOnly

The value that identifies a variable cannot be modified after initialization.

Ref

Identifies a parameter that may be affected by a parameter value.

Return

A jump statement for jumping out of a method. Execution is returned to the method caller.

SByte

Represents a simple type of 8-bit signed integer.

Sealed

Prevents types from being derived, preventing methods and property from being overwritten.

Short

Represents a simple type with signed integer values.  

sizeof

An operator that returns the length of a value type in bytes.

Stackalloc

Returns a pointer to a block of memory allocated on the heap.

Static

A static member is associated with the type in which it is declared, not the entity of the type.

String

A predefined reference type that represents a Unicode string. is an alias for the System.String predefined type.

struct

A Struct is a value type that can declare constants, fields, methods,property, indexers, operators, constructors, and inline types.

Switch

A selection statement that performs a list of statements associated with the expression matching label.

This

Refers to the current entity of a type.

Throw

Causes an exception to be thrown.

True

A Boolean literal.

Try

One of the components of the exception handling code block. Try the code block includes code that might throw an exception. See catch and finally keywords.

typeof

An operator that returns the type of the passed-in parameter.

UInt

A simple type that represents a four-bit unsigned integer value.

ULong

A simple type that represents a four-bit unsigned integer value.

Unchecked

Prevent overflow checking.

Unsafe

Labels the code block, method, or class that contains the pointer action.

UShort

Represents a simple type of a non-signed integer value.

Using

When used with namespaces, theusing keyword allows access to the type in that namespace without specifying its full name. Also used to define The scope of the finalization operation.

Virtual

A method modifier that identifies a method that can be covered by a vent.

void

The return type of the no return value method.

Volatile

Identifies a attributethat can be modified by the operating system, certain hardware devices, or concurrent threads.

While

The while condition statement executes one or more 0 or more times depending on the condition. The while part of the DO statement specifies the loop abort condition.

4. Named variables

▲ The name does not begin with an underscore

▲ do not create identifiers that are only case-sensitive, because in applications developed in other languages, it is not good to reuse classes, perhaps those languages are case-insensitive

▲ name starts with lowercase letters

▲ in identifiers that contain multiple words, start with the second word and capitalize the first letter

5, C # does not allow the use of unassigned variables.

6. Solution files using the. sln suffix as the extension, a solution can contain multiple projects. The project file uses the. csproj extension.

7, if the expression 0.0/0.0, the result is Nan (not a number), if the calculation 10+nan, the result is Nan, if the calculation infinity (infinity) +10, the result is infinity, but infinity*0, the result is 0,nan* 0 The result is Nan. The modulo operator applies to all numeric types, and the result is not necessarily an integer.

variables, operators, expressions

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.