C# 如何编辑绑定列表中的实例?

C# 如何编辑绑定列表中的实例?,c#,winforms,C#,Winforms,我有一个绑定列表: private static BindingList<Player> players = new BindingList<Player>(); 您在此处使用了错误的语法: location = players.location 您必须使用: location = player.location 因此,您的代码应该是: { int location; foreach (list player in players

我有一个绑定列表:

private static BindingList<Player> players = new BindingList<Player>();

您在此处使用了错误的语法:

      location = players.location
您必须使用:

      location = player.location
因此,您的代码应该是:

{
   int location;
   foreach (list player in players)
       {
       location = player.location;
       ctrl = MapSquareNumToTablePanel(location);
       crtl.containsplayers = true;
       }

}

您有什么问题?您可以对列表中的某个玩家设置一个值,设置方式与不在列表中的玩家相同。它们是参考资料。因此,在循环中只需执行
player.Property=newValue谢谢Dave,我该如何为players
部分中的每个玩家编写
?请参见上面编辑的代码。。。无论如何,我相信你对VB.NET和C有点困惑-你的语法混合了两者。请看这个链接:我只是在做一个我试图编写的代码的模型,这就是为什么它看起来像VBF,FOR循环的等价物是什么?我相信你不能在一个通用的FOR-NEXT中执行LIST,但是如果是这样,你可以使用类似于players(0)、location、players(1)、location等等的索引-就是这样。
{
   int location;
   foreach (list player in players)
       {
       location = player.location;
       ctrl = MapSquareNumToTablePanel(location);
       crtl.containsplayers = true;
       }