如何获得变量计数达到的最高值? [英] How to get the highest value reached by variable count?

查看:64
本文介绍了如何获得变量计数达到的最高值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach(string s in Array)
{
    if (file.exists(s))
    {
        count++;
    }
}



现在我希望在COUNT中达到最高价值?将它放入全局变量。


Now i want to get the HIGHEST VALUE reached in my "COUNT"? to put it into Global variable.

推荐答案

我不完全明白全局变量是什么意思,因为你在C#中定义的所有东西都是类。所以我假设你有一个名为 Global 的类,其静态字段或属性名为 NumberOfExistingFiles 的类型它与变量计数的类型相匹配。



I don''t exactly get what you mean by "global variable" as everything you can define in C# is part of a class. So I''ll just presume you have a class called Global with a static field or property called NumberOfExistingFiles the type of which matches the type of variable count.

foreach(string s in Array)
{
    if (file.exists(s))
    {
        count++;
    }
}
Global.NumberOfExistingFiles = count;





这就是全部!



问候,

- Manfred


这篇关于如何获得变量计数达到的最高值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆