0
Please explain why the result of this code is like this. I don't understand.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int x = 2; Console.WriteLine(x<<2); } } }
3 Réponses
+ 2
the "x<<2" shifts all the bits of the variable x to 2 places left, going from
00000010 to 00001000, which is 8
did you want to print out 2? you should remove the "<<2" part and leave only x
0
No I didn't want to print out 2. I wanted to know what this statement meant. Thank you for answering though.