gpt4 book ai didi

c# - C#中是否存在“增量按位移位运算符”?

转载 作者:太空宇宙 更新时间:2023-11-03 17:44:39 27 4
gpt4 key购买 nike

假设我想将数字按位移位,即

1, 2, 4, 8, 16, etc

Is there a way to condense the i = i << 1 below to something like increment operator (++)?

for (int i = 1; i <= 256; i = i << 1)
{
Console.WriteLine(i);
}

最佳答案

您的意思类似于<<=

full list of C# operators

关于c# - C#中是否存在“增量按位移位运算符”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7497025/

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