117

I saw a loop which I've never seen before:

for (int i = 0; i < (1 << list.Count); i++)

I can't understand what (1 << list.Count) means, maybe someone could explain me this?

Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
user2412672
  • 1,459
  • 3
  • 20
  • 36
  • 5
    Yes. Definitely a duplicate. Also something that probably should've been googled first. Also, I can't believe the number of comments that call using shift operators "unreadable." Maybe if you had 10 of them on the same line or something, but a shift operator is a very, very basic operator and "<<" has been the pneumonic for it in many languages since the 1960s. It's the kind of thing you learn in the first week of a programming class. Using Math.Pow() instead of << for a power of two on an integer is the point at which I consider firing the programmer. You're talking hundreds of cycles vs. 1. – reirab Jan 29 '14 at 22:51

0 Answers0