求助一BitVector32 问题

msl_0722 2008-07-15 10:49:01
哪位高手能给我讲下下面的题答案中参数1和-1的区别.
You are developing an application to assist the user in conducting electronic surveys. The survey consists of 25
true-or-false questions.
You need to perform the following tasks:
Initialize each answer to true.
Minimize the amount of memory used by each survey.
Which storage option should you choose?
A. BitVector32 answers = new BitVector32(1);
B. BitVector32 answers = new BitVector32(-1);
C. BitArray answers = new BitArray (1);
D. BitArray answers = new BitArray(-1);
Answer: B
...全文
179 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ting_na 2010-12-23
  • 打赏
  • 举报
回复
对于内部使用的布尔值和小整数,BitVector32 比 BitArray 更有效。BitArray 可以按需要无限地扩大,但它有内存和性能方面的系统开销.
位向量bitVector32, 用默认构造函数创建了一个BitVector32,其中所有的32位都初始化为false。构造函数传入的值如果为1,则结果会再加1,相当于结果没有变化,所以还是false,即应传入-1来表示结果做了取反的变化。是数据结构中的内容。
gomoku 2008-07-15
  • 打赏
  • 举报
回复

decimal hexadecimal binary
-1 = 0xffffffff = 11111111,11111111,11111111,11111111

So we have 32 trues at the begining.
周公 2008-07-15
  • 打赏
  • 举报
回复
不太清楚。

111,056

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧