Mik*_*ray 1 c# assignment-operator visual-studio-2019
我正在使用Visual Studio 2019研究C#中的赋值运算符,但由于错误代码CS0193,该脚本未运行。
首先,像{c = + a}一样,更改了“ =”等号后的“ +”加号的位置,但仅适用于add和sub。我想使用{c * = a}但出现以下错误。
int a = 21;
int c =+ a;
Console.WriteLine("1. Value of c is {0}", c );
Console.WriteLine("2. Binery of c is {0}", Convert.ToString(c, 2));
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
根据我的书很好,它应该像(x-= y),(x + = y),(x * = y)一样工作...但是在Visual Studio 2019中,它的工作原理像(x =-y),(x = + y ),错误,错误…
错误代码:CS0193
说明:*或->运算符必须应用于指针。
运算符以结尾而=不是开头=。所以用*= += -= /=。
当您键入int c =+ a解析为:
int c = +a; // evuivalent to: int c = a
Run Code Online (Sandbox Code Playgroud)
当您键入时int c =* a,解析为:
int c = *a; // error unless a is a pointer.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
78 次 |
| 最近记录: |