VB programmer's eyes in the eyes of C # 8

zhaozj2021-02-08  197

By using readonly, we can set a value in the constructor or in the initial number, which will not be modified after this value.

For example, we set a property called Color to Readonly:

Public Static Readonly Color Red;

Structs

The Struct in C # is a synthetic data type, consisting of some elements or data types. We can compare it to user-defined types in VB. such as:

Struct Point

{

Public int x;

Public int y;

}

Then you can reference this Struct as follows:

Point P1;

P1.x = 10;

P1.y = 10

AS

The AS operator is used to check the type of the left operand, if possible, convert it into the right operand. such as:

INT A as b;

If 'A' can be converted into 'b', this conversion is performed.

IF

There is no 'Then' or 'elseif' statement in C #, which is not like VB. The following is a comparison of the IF statement in VB and C #:

In VB:

IF size <60 then

Value = 50

END IF

In C #:

IF (SIZE <60);

Value = 50;

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

New Post(0)