Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi why, in what condition Temp1, Temp2, Temp3 is not bying outputed

public static readonly Queue<string> GetTemps = new Queue<string>(new string[] { "Temp1", "Temp2", "Temp3", "Temp4", "Temp5", "Temp6" });

        public NmView()
        {
            Queue<string> qu = ItemData.GetTemps;

            MessageBox.Show("Count: " + qu.Count);

            foreach (string item in qu)
            {
                MessageBox.Show(item);
            }
        }

Output Count: 3, Temp4, Temp5, Temp6


What I have tried:

googling, askt on few discord chanels no answer so far...
Posted
Updated 4-Feb-20 1:29am
Comments
phil.o 4-Feb-20 7:08am    
Put a breakpoint on the first line of the NmView method, press F5, and inspect the contents of the qu variable. Is there a chance that you already called the Dequeue method 3 times before calling the NmView method?
Valteris Eidukevicius 4-Feb-20 7:15am    
There are 2 user controls that uses GetTems so ading those + test 3 cals in total does that breaks something ?
Valteris Eidukevicius 4-Feb-20 7:18am    
Queue<string> is a class and i am simply clearing its instance with deque, so solution would by pasing copy ?
phil.o 4-Feb-20 7:21am    
Whenever you call the Dequeue method, then the first element is returned AND removed from the queue. If you don't want to remove the element, use the Peek method instead.
Queue<T> Class[^]
Valteris Eidukevicius 4-Feb-20 7:43am    
Peek seams to by messing with iterations, passing a copy seams to by right way

1 solution

Kinda was dum simple thind on which i wasted alot of time, Solution:
public static Queue<string> GetTemps => new Queue<string>(new string[]  
    { "Temp1", "Temp2", "Temp3", "Temp4", "Temp5", "Temp6"});
 
Share this answer
 
v4

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