-4

I didn't find any thing online about this function this is the example code

class Program
    {
        static void Main(string[] args)
        {
            int num1 = 20;
            int num2 = 30;
            num1 ^= num2;
            Console.WriteLine(num1 + "," + num2);

        }
    }
Hade Zedan
  • 21
  • 2
  • Does this answer your question? [XOR Operator - How does it work?](https://stackoverflow.com/questions/18239755/xor-operator-how-does-it-work) and [What is C# exclusive or `^` usage?](https://stackoverflow.com/questions/6422329/what-is-c-sharp-exclusive-or-usage) –  Jun 01 '21 at 01:58
  • It's one or the other but not both or neither at bits level https://en.wikipedia.org/wiki/Bitwise_operation#XOR –  Jun 01 '21 at 01:58
  • 2
    Does this answer your question? [C# compound assignment operator ^=](https://stackoverflow.com/questions/5744793/c-sharp-compound-assignment-operator) – D M Jun 01 '21 at 01:59
  • [Real world use cases of bitwise operators](https://stackoverflow.com/questions/2096916/real-world-use-cases-of-bitwise-operators) | [Applicable Uses of the XOR Operator](https://medium.com/@claireli_ultron/applicable-uses-of-the-xor-operator-3e0fcc9bf9cb) | [XOR - The magical bitwise operator](https://hackernoon.com/xor-the-magical-bit-wise-operator-24d3012ed821) –  Jun 01 '21 at 02:04
  • [This is documented](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/) – ProgrammingLlama Jun 01 '21 at 02:14
  • 1
    Given at all those online links, it would seem your online research skills could be improved – Ňɏssa Pøngjǣrdenlarp Jun 01 '21 at 02:36
  • @ŇɏssaPøngjǣrdenlarp However, it must be admitted that the search engines do not return anything suitable for "c# ^" or "c# ^ operator"... I think it is mainly a question here of a lack of basic training by using a good tutorial or a good book mentioning the classic list of operators at the very beginning, in addition to the control structures and the most important keywords. That said looking for `^` brings it there that does not help: https://en.wikipedia.org/wiki/Circumflex while the french page mention it: https://fr.wikipedia.org/wiki/Accent_circonflexe#En_sciences. –  Jun 01 '21 at 02:42
  • 1
    I will concede nothing of the sort. *online searching* is just a part of **research**. one key element is to acquire the relevant vocabulary, so the neophyte can understand what is written about the topic as well as ask even better subsequent questions. searching `c# operators ^=` yields **[C# operators and expressions](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/)** the only magic is *learning* that `^` is called an operator – Ňɏssa Pøngjǣrdenlarp Jun 01 '21 at 02:55
  • @ŇɏssaPøngjǣrdenlarp Indeed **c# operators ^=** brings you to the right place! But **c# operator ^=** is very less good –  Jun 01 '21 at 03:00

2 Answers2

0

The ^ operator means XOR. num1 ^= num2 would assign num1 to num1 XOR num2 by bits.

j1mbl3s
  • 994
  • 3
  • 16
0

It means num1 = num1 ^ num2;.

Check out Logical exclusive OR operator ^ and Compound assignment

Gellio Gao
  • 835
  • 6
  • 19