Sample code below is just a short one, my real code for one if statement is more than 1000 lines of code and those need to be called multiple times. So, to save lines I plan on putting it into a method and just calling that method, which is only around 1 line?
I was wondering if there is a possible way of putting multiple if else statements into MULTIPLE methods, and then calling those methods in the main method. If Method SuperSignalQ1 is true, then it will check method SuperSignalQ2, and so on.
I need this because without the method, my current code is more than 900k, which crashes my PC. This is the only way I could think of shortening my code, by putting it into a method and calling it in the main method as needed, rather than typing those 100s of lines everytime I need those.
So basically my question is:
- How to call a method in the main method
- How to check if that method is true so that it can then proceed to the next method. I receive error when doing the code in the MainCalculation
Cannot convert method group 'SuperSignalQ1' to non-delegate type 'bool'. Did you intend to invoke the method?
public void SuperSignalQ1()
{
if(RSI > RSI2)
{
if(CCI > CCI2) //There are actually more than 20 if else here which is around 1000 lines
{
return;
}
}
}
public void SuperSignalQ2()
{
if(RSI2 > RSI3)
{
if(CCI2 > CCI3) //There are actually more than 20 if else here which is around 1000 lines
{
return;
}
}
}
public void SuperSignalQ3()
{
if(RSI3 > RSI4)
{
if(CCI3 > CCI4) //There are actually more than 20 if else here which is around 1000 lines
{
return;
}
}
}
public void MainCalculation()
{
if (SuperSignalQ1 = True)
{
if(SuperSignalQ2 = True)
{
if SuperSignalQ3 = True)
{
SetColor(Color.White);
}
}
}
}
So basically, put multiple nested if statement into multiple methods, and then do an boolean check of those methods in the main method
Aucun commentaire:
Enregistrer un commentaire