jeudi 25 juillet 2019

How to simplify C# code with IF conditions [on hold]

Is there some decision to simplify C# code with many IF conditions? I think many if conditions need many proccess time Here is my code:

public double volume;
public double progressBar;
If(volumeValue >= 10 && volumeValue <20)
{
ProgressBar +=1;
}
If(volumeValue >= 20 && volumeValue <30)
{
ProgressBar +=1;
}
If(volumeValue >= 30 && volumeValue <40)
{
ProgressBar +=1;
}
If(volumeValue >= 40 && volumeValue <50)
{
ProgressBar +=1;
} 
If(volumeValue >= 50)
{
ProgressBar +=1;
}

Aucun commentaire:

Enregistrer un commentaire