tôi có mã này:Làm thế nào để làm cho mảng int Nullable?
var contractsID = contracts.Select(x => x.Id);
int?[] contractsIDList = contractsID.ToArray();//for debug
Trong dòng này:
int?[] contractsIDList = contractsID.ToArray();//for debug
tôi nhận được lỗi này:
Can not implicitly convert type int[] to int
những gì tôi cố gắng làm là làm cho contractsIDList Nullable loại.
Làm thế nào để tạo mảng int Nullable?
[C# Nullable mảng] (http://stackoverflow.com/question/16069997/c-sharp-nullable-arrays) –
Tại sao bạn muốn một mảng nullable? Là một kiểu tham chiếu, nó đã là nullable. –
Tôi không hiểu thông báo lỗi. Có phải 'x.Id' là' int? 'Hay' int'? Bạn có thực sự muốn tạo một 'int? []' Từ một 'int []'? –