在C Sharp中浏览数组 [英] navigating through an array in c sharp

查看:115
本文介绍了在C Sharp中浏览数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用按钮浏览数组并在导航时在单个标签上显示每个内容.thanks

How can navigate through an array using a button and display each content on a single label while navigating.thanks

推荐答案

创建一个类级别的整数(称为index),并将其初始化为零.
在您的表单加载事件中,将标签Text属性设置为array[index++].ToString()
在按钮Click事件处理程序中,查看index的值.
如果小于array.Length,则将标签Text属性设置为array[index++].ToString()

如果您使用的是基于Web的解决方案,则需要对此稍加复杂,以使用Session来存储值,或使用Javascript处理该值.
Create a class level integer (call it index), and initialize it to zero.
In your Form load event, set the label Text property to the array[index++].ToString()
In the button Click event handler, look at the value of index.
If it is less than array.Length, then set the label Text property to the array[index++].ToString()

If you are using a web based solution, then you need to complicate this slightly to use use a Session to store the value, or handle this in Javascript.


这篇关于在C Sharp中浏览数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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