将值分配给列表会产生麻烦

将值分配给列表会产生麻烦

问题描述:

大家好。我有这样的界面:



Hi everybody. I have such interface:

public interface IChannel
    {
        string Tag { get; }
        float Value { get; set; }
    }





在我班上我创建了一个列表如:



and in my class I create a list like :

List<IChannel> channels = new List<IChannel>();





然后我用值填充列表,最后我想更改列表中的值。我是这样做的:



Then I fill a list with values and finally I want to change the value in the list. I do it this way:

channels.ForEach(x=>
                   {
                       if (x.Tag == "LASV")
                           x.Value = a;
                   });



但带有标签LASV的元素的值不存在不要改变。有什么想法?


but the value of an element with tag "LASV" doesn''t changes. Any ideas why?

调试应用程序时,在 x.Value = a; 上设置断点>线。如果您的程序没有在此断点处停止,那么您没有x.Tag ==LASV的通道实例。您也可能希望确保外壳也正确。
When you debug your application, set a breakpoint on the x.Value = a; line. If your program does not stop on this breakpoint then you don''t have an instance of channels where x.Tag == "LASV". You also may wish to ensure that the casing is correct as well.


问题出在类中,即从寄存器读取数据并将其设置为变量Value。
The problem was in class, that was reading data from registers and setting it to the variable Value.