C#,试图检测列表的开始/结束状态 [英] C#, trying to detect start/end states of a list

查看:72
本文介绍了C#,试图检测列表的开始/结束状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决。答案解释了一切。



编辑:对不起。我不是故意删除所有内容。请将帖子恢复到原来的状态,以便将来的帖子可以提供帮助。



我尝试了什么:



Resolved. Answer explains everything.

I am sorry. I didn't mean to delete everything. Please revert the post back to its original state for future people who the post may help.

What I have tried:

Resolved. Answer explains everything.

推荐答案

只需添加到您的DisplayPerson方法:

Just add to your DisplayPerson method:
buttonPrevious.Enabled = birthdays.IsPerviousPerson();
buttonNext.Enabled = birthdays.IsNextPerson();





但是......我会使用属性而不是方法:



But ... I'd use properties instead of methods:

public bool HasNextPerson
        {
            get {return currentPerson < (people.Count - 1);}
        }
 
        public bool HasPreviousPerson
        {
            get {return currentPerson > 0;}
        }

然后说:

And then say:

buttonPrevious.Enabled = birthdays.HasPerviousPerson;
buttonNext.Enabled = birthdays.HasNextPerson;


这篇关于C#,试图检测列表的开始/结束状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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