c# - initialization of two variables at the same time -
is there way initialize these 2 variable @ same time?
in example "time" variable can "" or has value.
var variable1 = string.isnullorempty(time) ? string.empty : "value"; var variable2 = string.isnullorempty(time) ? "value" : string.empty;
not possible. can create helper class hold 2 variables. or can use out-of-the-box, tuple:
var variable = string.isnullorempty(time) ? tuple.create(string.empty, "value") : tuple.create("value", string.empty); and access 2 values variable.item1 , variable.item2.
note: use wisely variables in general better because have names, , hence - meaning. many tuples item1 , item2 can fast become unclear, intended for.
Comments
Post a Comment