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); } } }

28th Aug 2018, 11:49 PM
Daniel Ade
Daniel Ade - avatar
3 Answers
+ 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
29th Aug 2018, 6:07 AM
Data
Data - avatar
0
No I didn't want to print out 2. I wanted to know what this statement meant. Thank you for answering though.
29th Aug 2018, 3:56 PM
Daniel Ade
Daniel Ade - avatar