11
A
回答
14
這是二進制XOR
運算符。
二進制^運算符是爲 預定義的整型和布爾值。對於 整型,^計算其操作數的異或運算。對於bool 操作數,^計算邏輯 排斥或其操作數;即 只有當其中一個操作數爲真時 結果爲真。
1
看看MSDN ^ Operator (C# Reference)
0
4
^字符或'caret'字符是一個按位XOR操作符。 例如
using System;
class Program
{
static void Main()
{
// Demonstrate XOR for two integers.
int a = 5550^800;
Console.WriteLine(GetIntBinaryString(5550));
Console.WriteLine(GetIntBinaryString(800));
Console.WriteLine(GetIntBinaryString(a));
Console.WriteLine();
// Repeat.
int b = 100^33;
Console.WriteLine(GetIntBinaryString(100));
Console.WriteLine(GetIntBinaryString(33));
Console.WriteLine(GetIntBinaryString(b));
}
/// <summary>
/// Returns binary representation string.
/// </summary>
static string GetIntBinaryString(int n)
{
char[] b = new char[32];
int pos = 31;
int i = 0;
while (i < 32)
{
if ((n & (1 << i)) != 0)
{
b[pos] = '1';
}
else
{
b[pos] = '0';
}
pos--;
i++;
}
return new string(b);
}
}
^^^ Output of the program ^^^
00000000000000000001010110101110
00000000000000000000001100100000
00000000000000000001011010001110
00000000000000000000000001100100
00000000000000000000000000100001
00000000000000000000000001000101
相關問題
- 1. @字符在jQuery中做了什麼?
- 2. ∴字符在bash shell中做了什麼?
- 3. @前綴對C#中的字符串文字做了什麼?
- 4. extern在目標C中做了什麼?
- 5. 「12345」+ 2在C中做了什麼?
- 6. MAX在Objec-C/cocos2d中做了什麼?
- 7. arraylist IndexOf在asp.net/c#中做了什麼?
- 8. '|| ='操作符在ruby中做了什麼?
- 9. &符(「&」)在put語句中做了什麼?
- 10. 'b'字符在字符串面前做了什麼?
- 11. C++:&rand做了什麼?
- 12. %di說明符在C編程中做了什麼?
- 13. 「+」在CSS中做了什麼?
- 14. App = EntityFramework在Sql連接字符串中做了什麼?
- 15. Python在Python中對字符串做了什麼?
- 16. *在C中做什麼符號?
- 17. 「| =」運算符在C#中做什麼?
- 18. 這個':'運算符在下面的C++代碼中做了什麼?爲什麼?
- 19. '@@'在sqlplus提示符上做了什麼?
- 20. {}在字符串中做什麼?
- 21. '`'字符在Perl中做什麼?
- 22. '@'在c#中做什麼?
- 23. crypt()在C中做什麼?
- 24. typedef在C++中做什麼
- 25. 在C中,'''做什麼?
- 26. ruby字符串中的#{}實際上做了什麼?
- 27. 我在做什麼錯了?
- 28. perl中的~~做了什麼?
- 29. scalaz中scalaz.syntax.std.OptionOps.cata做了什麼?
- 30. 什麼是「?」。運算符在C#中做什麼?
http://stackoverflow.com/q/3735623 – Alex 2011-03-04 10:42:46
的 「^」 在C#,或其中至少整個.NET文檔顯示沒有任何解釋,是「處理的附加使用以反對運營商。「這是一個標記垃圾收集對象的C++事物,因此您不必擔心自己的內存管理問題。它遍佈MSDN .NET文檔,例如'SomeMethod(String ^,IDictionary ^)',但實際上並沒有在任何地方解釋。在Google或SE中出現的關於C#中「^」的唯一情況就是「XOR」的答案,這是完全不同的。 https://msdn.microsoft.com/en-us/library/yk97tc08.aspx –
mc01
2017-05-09 20:21:10
這是我正在尋找的答案。 – 2017-05-31 21:13:10