新手求助,C#的第一个,上一个,下一个,最后一个,内详,急!

[复制链接]
查看11 | 回复4 | 2012-5-30 09:54:45 | 显示全部楼层 |阅读模式
public static string s ="23,56,11,76";
string[] strs = s.Split(',');
//装进数组
public static int index = 0;
//设置下标//获得相应按钮点击后的数字
public string GetValueStr(int index)
{
if (index > strs.Length-1)
{
index = s...
回复

使用道具 举报

千问 | 2012-5-30 09:54:45 | 显示全部楼层
string[] strs = s.Split(','); // 先把string拆分成字符串数组:“第一个”button的事件中写:label1.Text = strs[0];“上一个”button的事件中的思路:1.获得当前显示的string的索引currentIndex2.判断currentIndex-1的值,如果不小于0(这个很重要,要不然...
回复

使用道具 举报

千问 | 2012-5-30 09:54:45 | 显示全部楼层
int index=i;string[] array=s.split(',');protected void btnFirst_Click(object sender,EventArgs e){
this.Label=array[0]; index=0;}protected void btnPrev_Click(object sen...
回复

使用道具 举报

千问 | 2012-5-30 09:54:45 | 显示全部楼层
正怒月神 的代码因为值类型,index调用的是副本,会有BUG。我加了ref关键字,引用传值,BUG解决string s ="23,56,11,76";
string[] strs = s.Split(',');
//装进数组
int index = 0;...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行