gpt4 book ai didi

c# - 递增和递减运算符 C#

转载 作者:太空宇宙 更新时间:2023-11-03 20:59:56 25 4
gpt4 key购买 nike

<分区>

我不确定我是否真的应该在这个网站上发布问题,但就这样吧。我正在阅读 Essential C# 6.0,我遇到了这段

The result of the prefix operators is the value that the variable had before it was incremented or decremented. The result of the postfix operators is the value that the variable had after it was incremented or decremented.

我想至少读了 10 遍,但对我来说,它似乎与下面的代码完全相反(这不是书中的代码)。任何人都可以解释这是我做错了什么还是只是书中的错误?顺便说一句,我还检查了勘误表,但在那里找不到。

using System;

public class Program
{
public static void Main()
{
var a = 23;
var b = 23;

var c = a++; //postfix
var d = ++b; //prefix

Console.WriteLine(c); //23
Console.WriteLine(d); //24

}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com