C# Programming Tutorials: Beginners 10 Binary and Bitwise Operators


Part of the series of tutorials on programming C# for beginners

Takes a look at binary and bitwise operators, where and how they are used

Source code:


Xem Thêm Bài Viết Khác:https://wijstaanvooronzegrondrechten.org/cong-nghe


  1. Is there a low-cost way to ignore every other byte? I have an image where I only care about the first byte, because I want to truncate a 12-bit image to 8-bit. Basically I want to reduce the size of the memory buffer by half by taking only the most significant bytes.

  2. I have struggled to fully understand bitwise operations for years. This short video helped me more than any other resource I’ve used before now. THANK YOU!!

  3. When using the windows calculator to do a bitwise you have to press the Lsh or Rsh button followed by the amount of shifts you want to perform.

  4. Hi, Luke! I know this is old video, but I also know, that you answer most comments typically.
    My colleague recently gave me this awesome example of bitwise logic (he mentioned, that it was found out by some famous programmer (I forgot his name), who also happenes to be a good mathematician.


    value1 ^= value2 ^= value1 ^= value2.

    This swaps variables values without having any temp third variables to store the value. Value can by of any type, as he said (if I remember correctly).

  5. i guess one way I might remember what ^ does is that it's the "is contested?" operator. as in, are two people on opposite ends of an opinion? if so, true.

  6. is "d ^= true" really better than "d = !d" ? I'd argue that the second one is a lot more readable since XOR isn't really that common to use in normal code. At least not in my experience.

  7. Are there any ways to use OR on an enum like you showed, but extract the multiple options the user has chosen(like blue and white)

  8. Great tutorials, I'm enjoying them immensely.

    I'm coming from VB (I know!!!), VB.Net, VBA, ASP.net background, although I have also written a few, fairly rushed C# programs, I'm watching these more for good programming practice and to quickly fill in any big gaps in my knowledge – this tutorial being one such example.

    If there is one thing I will take from these tutorials, it is the proper documentation of code, I have been shamefully neglectful of this in the past 🙁

    I have a couple of questions, if you don't mind, do you have any plans to cover MVC and where are you from – my guess is South Manchester 🙂

    Anyway, thanks again for the tutorials – superb stuff.


Please enter your comment!
Please enter your name here