I’m not a c# programmer at all, but need to get certain calculations from a C# app. No I ran into something that I’m not sure if what the output is
I have the following line of code
pageSizeFactor = PrintingRequirements.FormSize == FormSize.A4 ? 1 : 2;
I just need to confirm if I am correct, the above means the following, pageSizeFactor = the Formsize, so if the Formsize is A4 pageSizeFactor will be 1 else it will be 2?
Yes; if
PrintingRequirements.FormSizeisFormSize.A4,pageSizeFactorwill be 1. Otherwise, it will be 2.That operator (
?:) is known as the conditional operator. It is also sometimes known as the ternary operator. Its syntax goes like this:If
aevaluates totrue, the result will beb; otherwise, it will bec.