如何在按钮单击下依次向数组添加值。 [英] How to add values to an array one after the other under button click.

查看:70
本文介绍了如何在按钮单击下依次向数组添加值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在按钮单击下依次向数组添加值...我想将项添加到第0个索引,然后根据按钮单击添加第一个索引....

How to add values to an array one after the other under button click...I want to add items to the zeroth index and then the first index based on button click....

推荐答案

保持一个班级计数器并递增它。



例如

Keep a class level counter and increment it.

For e.g.
int arrayCount = 0;

private void button_Click(sender s, event e)
{
  sum += myArray[arrayCount++];
}


这篇关于如何在按钮单击下依次向数组添加值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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