WPF For Each不输出 [英] WPF For Each not outputting
本文介绍了WPF For Each不输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了一个问题,每个人在WPF试图让它出去我说错了什么
I am having an issue with a for each in WPF trying to get it to out put what am i doing wrong
Form1.cs
namespace boxes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
foreach green = new foreach();
textBox4.Text = green.person;
}
}
}
looparound.cs
class foreach
{
public string person { get; set; }
public void round()
{
List<string> demo = new List<string>();
demo.Add("Bob");
demo.Add("George");
demo.Add("Tom");
demo.Add("Sue");
foreach (string person in demo)
{
person.ToString();
}
}
}
}
推荐答案
" foreach"是保留关键字。请使用其他班级名称。
Hi,
"foreach" is a reserved keyword. Please use another class name.
在您的班级foreach中,您将字符串从demo分配给person。在foreach之后,财产人将是"苏"。并且您的TextBox1将显示"Sue"。
In your class foreach you assign the string from demo to person. After the foreach the property person will be "Sue" and your TextBox1 will show "Sue".
这篇关于WPF For Each不输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文