开发者

What is a equivalent of Delphi "shl" in C#?

开发者 https://www.devze.com 2023-02-17 09:20 出处:网络
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#.

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.


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


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


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号