等效于C#的位集翻转方法

编程入门 行业动态 更新时间:2024-10-21 23:24:16
本文介绍了等效于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的信息的链接 msdn.microsoft/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 msdn.microsoft/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#的位集翻转方法

本文发布于:2023-11-17 07:03:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609239.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!