c# - How to assign values for multiple class property like a list of items using for loop? -


i wish set list of properties @ same time, possible? thanks!

public class helper {     public bool { get; set; }     public bool b { get; set; }     public bool c { get; set; }      public void settofalse(list<property> abc)     {         // try set a, b, c false in loop         foreach (var item in abc)         {             item = false;         }     } } 

why want this: wish have clean way toggle boolean properties @ once, while cannot group properties list because context viewmodel , properties bound xaml.

i use list of rambda.

public class helper     {     public bool { get; set; }     public bool b { get; set; }     public bool c { get; set; }      public list<action<bool>> setters { get; set; }     public helper()         {         this.setters = new list<action<bool>>()              { b => this.a = b, b => this.b = b, b => this.c = b };         }      public void settofalse(ienumerable<action<bool>> setters)         {         // try set a, b, c false in loop         foreach (var in setters)             {             a(false);             }         }     } 

do this?


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -