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
Post a Comment