How to shorten it? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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; } #... } } }

27th Oct 2018, 8:20 AM
Road_to_ BigStar
Road_to_ BigStar - avatar
1 ответ
+ 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#).
27th Oct 2018, 10:37 AM
Paul
Paul - avatar