如何在數組中搜索我的ID,如果它找到我的ID,請將其保存在userseq
中。如果沒有找到,只返回消息(Messagebox.Show("Does not exist"))
數組的所有單元(我整理搜索shows only one message
)後,平均如何搜索陣列並顯示一條消息
for (int yu = 0; yu <= 92161; yu++)
{
int wer = d[yu];
if (wer == sc)
{
userseq = yu;
}
}
PS:我通過
int? userseq=null;
...........
(!userseq.HasValue)
{
Messagebox.Show("Does not exist")
}
你現在的代碼有什麼問題?你有任何錯誤?它是否不返回預期的輸出(如果不是,那麼它返回什麼以及預期的結果是什麼)?看起來也許你只是忘了在'if(!userseq.HasValue)'行的開頭添加'if'? – BateTech
當我向系統插入錯誤的編號時,它仍然顯示一些不正確的結果。如果在這裏,我忘了添加,但是在我使用它的代碼中。另外我不能使用int? userseq = NULL;因爲userseq是「int」但「null」是布爾值@BateTech – user3446681
你已經問了兩次,[這裏](https://stackoverflow.com/questions/22649451/how-to-add-condition-to-loop )和[這裏](https://stackoverflow.com/questions/22675342/how-to-stop-running-the-code-fragment)。其他答案不適合你的是什麼? –