It is a
Ternary Operator[
^].
Quote:
condition ? first_expression : second_expression;
For first line of code...
condition - DTLocal.Rows[0]["TruckReceiptDate"].ToString() == ""
first_expression - ""
second_expression - DateTime.Parse(DTLocal.Rows[0]["TruckReceiptDate"].ToString()).ToString("dd-MMM-yyyy"))
If condition is satisfied the
first_expression will be executed, otherwise
second_expression will be executed.
So, for first line...
txtTruckReceiptDate.Text = (DTLocal.Rows[0]["TruckReceiptDate"].ToString() == "" ? "" : DateTime.Parse(DTLocal.Rows[0]["TruckReceiptDate"].ToString()).ToString("dd-MMM-yyyy"));
Here it checks the value of
DTLocal.Rows[0]["TruckReceiptDate"].ToString()
.
And
->
if the value is
""
, it assigns
""
to
txtTruckReceiptDate.Text
,
->
otherwise it assigns
DateTime.Parse(DTLocal.Rows[0]["TruckReceiptDate"].ToString()).ToString("dd-MMM-yyyy"))
to
txtTruckReceiptDate.Text