mardi 14 juillet 2020

How does multiple method calls in an if-statement work?

I am relatively new in C#.

I am trying to understand how the flowing bit of code is working.

public static int Method3()
{
 //some code
   If(Class1.Method1(int Variable1).Method2(Class3 Variable2))
   {
      //even more code
   }
 //some code
}

OK, now a bit of context.

This if-statement is in Method3 and Method3 is the Class Class1.

  • Method1 takes an Int value and returns NULL or an Class Class2.

  • Method2 takes a Class lets call it Class3 and it returns true or false.

So I understand for the if-statement to be valid the condition must return true or false.

Which will come from the Method2 from my understanding.

But what is Method1 doing here? What happens with the output of Method1? Does it have any influence to the condition?

I hope you guys can understand what I mean. If not please ask.

Aucun commentaire:

Enregistrer un commentaire