Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody. I have such interface:

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


and in my class I create a list like :
CSS
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:
C#
channels.ForEach(x=>
                   {
                       if (x.Tag == "LASV")
                           x.Value = a;
                   });

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

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.
 
Share this answer
 
Comments
Alexander Dymshyts 4-Jan-13 4:53am    
it stops on this breakpoint... but not assigns the value
fjdiewornncalwe 4-Jan-13 4:56am    
Interesting. I'm going to have to see if I can replicate this as well. Sorry I don't have a better answer right away.
fjdiewornncalwe 4-Jan-13 5:04am    
Have you double checked the value of a? I did a quick test and it seems to work. (Yes, I just said "It works on my box...")
Alexander Dymshyts 4-Jan-13 5:23am    
thnx for help. Problem was in another class that was reading data from registers
fjdiewornncalwe 4-Jan-13 5:25am    
Awesome. Glad you solved your issue. Cheers.
The problem was in class, that was reading data from registers and setting it to the variable Value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900