Question mark and colon in statement. What does it mean?

后端 未结 7 1475
南方客
南方客 2020-11-27 14:03

What do the question mark (?) and colon (:) mean?

((OperationURL[1] == "GET") ? GetRequestSignature() : "")
         


        
7条回答
  •  悲哀的现实
    2020-11-27 14:36

    It's a ternary operator, or the short form for if..else.

    condition ? value if true : value if false

    See Microsoft Docs | ?: operator (C# reference).

提交回复
热议问题