Is there any way to initialize these two variable at the same time?
in this example "time" variable can be "" or has a value.
var variable1 = string.IsNullOrEmpty(time) ? string.Empty : "value";
var variable2 = string.IsNullOrEmpty(time) ? "value" : string.Empty;
Not possible. But you can create some helper class to hold those two variables. Or you can use some out-of-the-box, like
Tuple:and then access those two values as
variable.Item1andvariable.Item2.Note: Use it wisely as variables are in general better because they have names, and hence - some meaning. Too many
Tupleswith all thoseItem1andItem2can fast become unclear, what they are intended for.