Cannot implicitly convert type int[] to int?[]

Viewed 2972

In my sample class it contain IdValues that is int?[]. The values is come from the other class that has an Id as a key field.

//Database class
public class SampleValues // this is a entity that i want to collect the deatil id
{
    public int Id { get; set; }
    public int?[] SampleDetailIdValue { get; set; }
}

public class SampleDetailValues // this is the detail entity
{
    public int Id { get; set; }
}


// The error code
if (sampleDetails.Count > 0)
{
    sample.IdValues = sampleDetails.Select(s => s.Id).ToArray(); // << The error occurred this line.
}

The error is Cannot implicitly convert type int[] to int?[]

2 Answers
Related