Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 对于int i=值_C#_Loops_Search_Return Value - Fatal编程技术网

C# 对于int i=值

C# 对于int i=值,c#,loops,search,return-value,C#,Loops,Search,Return Value,我正在尝试创建一些搜索值的代码 到目前为止,代码如下所示: private void button4_Click(object sender, EventArgs e) { uint randBuff = DLL.Extension.ReadUInt32(0x0154d6e4); for (int i = 0; i < 144705; i++) { randBuff = (randBuff + 4)

我正在尝试创建一些搜索值的代码

到目前为止,代码如下所示:

 private void button4_Click(object sender, EventArgs e)
     {
         uint randBuff = DLL.Extension.ReadUInt32(0x0154d6e4);
         for (int i = 0; i < 144705; i++)
         {
             randBuff = (randBuff + 4);
             listBox1.Items.Add(randBuff.ToString("x8")); 

         }            
     }
private void按钮4\u单击(对象发送者,事件参数e)
{
uint randBuff=DLL.Extension.ReadUInt32(0x0154d6e4);
对于(int i=0;i<144705;i++)
{
randBuff=(randBuff+4);
listBox1.Items.Add(randBuff.ToString(“x8”);
}            
}

我搜索的值是144705。其思想是在randBuff=144705时停止搜索该值。这可以通过循环来完成,还是有其他方法来完成

如果我正确理解你的问题,那么这更适合循环:

while (randBuff < 144705) 
{
  listBox1.Items.Add(randBuff.ToString("x8"));
  randBuff += 4;
}
while(randBuff<144705)
{
listBox1.Items.Add(randBuff.ToString(“x8”);
randBuff+=4;
}

基本上,只要randBuff小于目标值144705,将该值添加到列表框并将该值增加4。

您意识到这里没有搜索,对吗?向列表框中添加144705项可能不是您想要做的事情。这需要很大的内存。我不太理解“搜索”部分。
randBuff
是否为每次迭代增加四倍的偏移量?实际的搜索方在哪里(您在哪里检查是否找到了匹配的项目)?您到底要搜索什么?您只需从外部源中读取一次
uint
,然后在本地缓慢地增加它。谢谢,这是主要的想法!我会试试看,但应该管用。保存了我的一天。仍然有36177项添加到列表框中。“很可能会崩溃。”凯莫萨贝——我回答了他所问的问题。是的,它可能会崩溃,但这是另一个问题。既然他评论说这是他想要的,我就不值得投反对票。我同意,我没有投反对票you@KemoSabe-对不起,我不是故意暗示你这么做的