ทำไมไม่
int? nullInt = null;
base.Response.Data = (new BusinessLogic.RefDataManager(base.AppSettingsInfo)).SelectAppData(new DC.AppData() { AppDataKey = app_data_key != string.Empty ? app_data_key : null, AppDataTypeId = app_data_type_id != string.Empty ? int.Parse(app_data_type_id) : nullInt });
คอมไพล์แต่อันนี้
base.Response.Data = (new BusinessLogic.RefDataManager(base.AppSettingsInfo)).SelectAppData(new DC.AppData() { AppDataKey = app_data_key != string.Empty ? app_data_key : null, AppDataTypeId = app_data_type_id != string.Empty ? int.Parse(app_data_type_id) : null});
ไม่? ข้อผิดพลาดในการคอมไพล์สำหรับคำสั่งที่สองคือ "ไม่สามารถระบุประเภทของนิพจน์ตามเงื่อนไขได้เนื่องจากไม่มีการแปลงโดยนัยระหว่าง 'int' และ null"
DC.AppData คือ
public class AppData
{
[DataMember(Name = "AppDataKey")]
public string AppDataKey { get; set; }
[DataMember(Name = "AppDataTypeId")]
public int? AppDataTypeId { get; set; }
}