Does in c# all if statements were analysed before execution, so that in case an if statement can't be true (before proof all conditions) will be canceled?
My problem is, that i want to get rid of multiple if statements, becuase some methods in the if statement needs a long time to execute (which is wasted time if they were executed).
Here is a simple if statement (here it works). But how good is this on complex if statements?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace IfTest
{
class Program
{
static void Main(string[] args)
{
if (true || NeedALongTime())
{
Console.WriteLine("!");
}
Console.ReadLine();
}
private static bool NeedALongTime()
{
Thread.Sleep(10000);
return true;
}
}
}