PHP has a language construct list()that provides the assignment of several variables in a single expression.
$a = 0;
$b = 0;
list($a, $b) = array(2, 3);
Is there a similar thing in C #?
If not, is there any workaround that can help avoid code like the following without having to deal with reflection ?
public class Vehicle
{
private string modelName;
private int maximumSpeed;
private int weight;
private bool isDiesel;
public Vehicle()
{
}
public Vehicle(
string modelName,
int maximumSpeed,
int weight,
bool isDiesel
)
{
this.modelName = modelName;
this.maximumSpeed = maximumSpeed;
this.weight= weight;
this.isDiesel= isDiesel;
}
}
source
share