0
How to shorten it?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public int Speed=0; public value EngineVolume=0; namespace SoloLearn { class Program { static void Main(string[] args) { if Speed == 0{ EngineVolume = 0; } if Speed == 1{ EngineVolume = 1; } if Speed == 2{ EngineVolume = 2; } #... } } }
1 Réponse
+ 3
There are some errors in your code.
And if Speed and EngineVolume have the same value, why use both. Or say EngineVolume = Speed. Or use casting (or whatever typeswiching is called in c#).