What is a equivalent of Delphi “shl” in C#?

狂风中的少年 提交于 2019-12-08 03:38:01

问题


I'm making an application in C#, based on Delphi (converting code), but I found a command that I do not recognize (shl), and i want to know if there is any equivalent to C#.

Thanks in advance.


回答1:


Shl is left shift. Use << C# operator for the same effect.

Example:

uint value = 15;              // 00001111
uint doubled = value << 1;    // Result = 00011110 = 30
uint shiftFour = value << 4;  // Result = 11110000 = 240



回答2:


From Shl Keyword this is a bitwise shift left which from C# Bitwise Shift Operators would be <<




回答3:


Shl is the shift left operator, in C# you use <<.

var
  a : Word;
begin
  a := $2F;   // $2F = 47 decimal
  a := a Shl $24;
end; 

is the same as:

short a = 0x2F;
a = a << 0x24;


来源:https://stackoverflow.com/questions/5348540/what-is-a-equivalent-of-delphi-shl-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!