等效于C#的位集翻转方法 [英] C# Equivalent of bitset Flip method
本文介绍了等效于C#的位集翻转方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个需要翻转的BitArray.在C ++中,您可以仅使用以下语法:
I have a BitArray which I need to flip. In C++ you can just use the following syntax:
bitset<5> MyBitset (mystring);
MyBitset.flip();
如何在C#中获得相同的结果?另外,我现在需要获取此位集(好吧,在C#中为BitArray)并将其转换为双精度型.在C ++中,我只能使用.to_ulong()方法,但是C#没有给我该选项:/
任何帮助都会很棒!
预先感谢.
How can I achieve the same result in C#? Also, I now need to take this bitset (well, BitArray in C#) and convert it to a double. In C++ I can just us the .to_ulong() method, however, C# does not give me that option :/
Any help will be awesome!
Thanks in advance.
推荐答案
使用BitArray类的Not()方法.
这是有关BitArray的信息的链接
http://msdn.microsoft.com/en-us/library/system.collections. bitarray.aspx [ ^ ]
您可能想查看BitConverter类,也许可以帮助将BitArray转换为double.
Use the Not() method of the BitArray class.
Here is a link for info about BitArray
http://msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx[^]
Edit 2: You may want to check out the BitConverter class maybe it can help to convert BitArray to double.
这篇关于等效于C#的位集翻转方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文