小编Gm *_*sha的帖子

如何在循环中只显示一次消息框

我是New C in,

我正在使用messagebox来显示该行.但是它处于一个循环中,所以消息框显示的次数我想只显示一次,并且下次不应显示消息框.

try{
    using (var sr = File.OpenText("test.txt")){
        string newone = 20110501;//date
        string line;
        while ((line = sr.ReadLine()) != null){
            if (three => one){
                MessageBox.Show("Buy : " + line);
                //Its Displaying more than 50 times i want to displayit only
                //onetime and should dispose for the next Time
            }
        }
    }
} catch { }
Run Code Online (Sandbox Code Playgroud)

提前致谢.

c# loops while-loop

0
推荐指数
1
解决办法
9099
查看次数

标签 统计

c# ×1

loops ×1

while-loop ×1