什么做两左尖括号"<<"在C#是什么意思? [英] What do two left-angle brackets "<<" mean in C#?

查看:424
本文介绍了什么做两左尖括号"<<"在C#是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上在标题中的问题。我期待在MVC 2的源代码:

Basically the questions in the title. I'm looking at the MVC 2 source code:

[Flags]
public enum HttpVerbs {
    Get = 1 << 0,
    Post = 1 << 1,
    Put = 1 << 2,
    Delete = 1 << 3,
    Head = 1 << 4
}

和我只是好奇,以什么向左双角brackers << 确实

and I'm just curious as to what the double left angle brackers << does.

推荐答案

这将是的按位向左移位运营商。

有关离开每个班次,该值有效地2.因此,举例来说,写价值<相乘; 3 将乘以8的值。

For each shift left, the value is effectively multiplied by 2. So, for example, writing value << 3 will multiply the value by 8.

它真正做内部移动是所有价值的实际位数留下一个位置。所以,如果你有二进制值12(十进制),也就是 00001100 ;移动它留下一个地方都会把它转换成 00011000 ,或24。

What it really does internally is move all of the actual bits of the value left one place. So if you have the value 12 (decimal), in binary that is 00001100; shifting it left one place will turn that into 00011000, or 24.

这篇关于什么做两左尖括号&QUOT;&LT;&LT;&QUOT;在C#是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆