1

There are several statements in an existing project that includes ? and :.

I would like to understand what do they mean, and in the following statements, if they can be explained.

loginID = rawLoginID.Contains("\\") ? rawLoginID : domain + "\\" + rawLoginID;

string orgUnitCode = row[ORG_UNIT_CODE] != null
                     ? row[ORG_UNIT_CODE].ToString()
                     : string.Empty;

loginID = loginID.Contains("\\") ? loginID : domain + "\\" + loginID;

The syntax that I am not sure are ? :

Thank you.

gymcode
  • 4,163
  • 14
  • 61
  • 119
  • 2
    Documentation is usually the best place to start, the operators are called ternerary operator: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator – peeyush singh Jun 04 '19 at 02:19
  • Thank you @peeyushsingh. I will read the documentation. – gymcode Jun 04 '19 at 02:28

0 Answers0