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

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

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

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


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 14:35

    string requestUri = _apiURL + "?e=" + OperationURL[0] + ((OperationURL[1] == "GET") ? GetRequestSignature() : "");
    

    can be translated to:

    string requestUri="";
    if ((OperationURL[1] == "GET")
    {
        requestUri = _apiURL + "?e=" + GetRequestSignature();
    }
    else
    {
       requestUri = _apiURL + "?e=";
    }
    

提交回复
热议问题