locked
How to check if all values in dictionary are true? RRS feed

  • Question

  • User379720387 posted

    How does one check if all myConnectedClients.keyvalHasManualState are true?


    public class myClient { public IClient keyvalClient { get; set; } public string keyvalLocType { get; set; } public bool keyvalHasExistingManual { get; set; } } private Dictionary<string, myClient> myConnectedClients = new Dictionary<string, myClient>();

    Tuesday, April 2, 2019 1:23 AM

Answers

  • User-1174608757 posted

    Hi  wavemaster,

    According to your description, you could just use foreach to loop all the dictionary. You could loop the value of myConnectedClients then you could get attribute keyvalHasExistingManual. Here is a demo ,I hope it could help you.

    public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
               Dictionary<string, myClient> myConnectedClients = new Dictionary<string, myClient>();
                foreach (var item in myConnectedClients.Values)
                {
                    if (item.keyvalHasExistingManual == true)
                    {
                       
                    }
    else
    {


    }
    } } } public class myClient { public string keyvalLocType { get; set; } public bool keyvalHasExistingManual { get; set; } }

    Best Regards

    Wei

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 2, 2019 5:50 AM