S
shapper
Hello,
I have the following:
if (tp.Weight >= 80) {
tp.Weight = 80;
}
else if (tp.Weight >= 60) {
tp.Weight = 60;
}
else if (tp.Weight >= 40) {
tp.Weight = 40;
}
else if (tp.Weight >= 20) {
tp.Weight = 20;
}
else {
tp.Weight = 0;
}
Is there a way to make this code shorter? Just wondering ..
Note that I always give the same value as the one I am testing ...
Thanks,
Miguel
I have the following:
if (tp.Weight >= 80) {
tp.Weight = 80;
}
else if (tp.Weight >= 60) {
tp.Weight = 60;
}
else if (tp.Weight >= 40) {
tp.Weight = 40;
}
else if (tp.Weight >= 20) {
tp.Weight = 20;
}
else {
tp.Weight = 0;
}
Is there a way to make this code shorter? Just wondering ..
Note that I always give the same value as the one I am testing ...
Thanks,
Miguel