2015-03-19 75 views

回答

1

你只需要添加一些括號所以它是作爲單個語句塊處理...

<div> 
    @(string.IsNullOrEmpty(Model.Customer.State) ? Model.Customer.Country : string.Format("{0}, {1}", Model.Customer.Country, Model.Customer.State)); 
</div> 
+0

啊..我包裝了單個語句,但它不起作用謝謝! – Elisabeth 2015-03-19 10:53:00

1

你必須包住整個條件帶括號:

<div> 
    @(string.IsNullOrEmpty(Model.Customer.State) ? Model.Customer.Country : string.Format("{0}, {1}", Model.Customer.Country, Model.Customer.State)) 
</div>