获取所有要素 [英] Getting all the elements

查看:69
本文介绍了获取所有要素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的ASP代码:

This is my ASP code:

<form id="form1"  runat="server">
   <input type="submit"  runat="server"  önserverclick = "Checkout" />
   <br />
   <asp:Label runat="server" id="oop">
</form>



这是我的C#代码:



This is my C# code:

public void Checkout (object sender, EventArgs e)
   {
       string[] super = {"Bill" , "Dhoni" , "Jobs"};

       for (int i = 0; i < super.Length; i++)
       {
           oop.Text = super[i].ToString();
       }

   }



当我调试程序时,我只会得到乔布斯作为输出,而不是所有元素.

请帮我解决这个问题.
谢谢.



When I debug the program I only get Jobs as the output but not all the elements.

Please help me out with this.
Thank you.

推荐答案

代码正常运行.每次都覆盖oop.Text,因此它将具有数组中最后一项的值.
The code is functioning correctly. You are overwritting oop.Text each time so it will have value of the last item in your array.
oop.Text = super[i].ToString(); 



如果您希望它包含所有值,请执行此操作



If you want it to contain all values then do this

oop.Text += super[i].ToString();


尝试此oop.Text = oop.Text.ToString()+ super [i] .ToString();
try this oop.Text = oop.Text.ToString() + super[i].ToString();


这篇关于获取所有要素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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