Answer the question
In order to leave comments, you need to log in
How to create multiple numbers in c#?
I thought that you should not pile up the code with large ifs, because this is not correct.
The task is to constantly check several numbers that are static.
That is,
with what help should I structure them into a single whole so that there are not many "a==.."
I thought about implementing it with a loop, but it seems to me that this is not the right way at all
if (a==1 || a==2){}
Answer the question
In order to leave comments, you need to log in
string[] printer = {"jupiter", "neptune", "pangea", "mercury", "sonic"};
if(printer.Contains("jupiter")) {
// TODO
}
if (printer.Contains(a))
Create a function for your simple check and use it where you need it. Contains
of course it's fine if the check is not of type a > 7 && a % 2 == 0
.
static void Prow(int a){
switch(a){
case 1:/* выполнить необходимые действия */break;
case 2:/* выполнить необходимые действия */break;
case /* для остальных значений */:/* */break;}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question