I have a struct named CheckedNumber. This type is used in a property:
`public IList<CheckedNumber> CheckedNumbers { get { return this._checkedNumbers; } }`
…to keep a list of numbers.
I have another property:
`public int? TheNumber { get { return this._theNumber; } }`
…and want to check if its value exists in the CheckedNumbers list.
this:
if (this.CheckedNumbers.Contains(this.TheNumber)) { //... }
gives error:
Argument 1: cannot convert from 'int?' to 'ProjectName.Models.CheckedNumber'
How could I convert int? to my struct type?
Okay, now the question is slightly clearer – but fundamentally, you’re asking whether a list of
CheckedNumbervalues contains a particularint?value. That makes no sense, as anint?isn’t aCheckedNumber– it’s like asking whether aList<Fruit>contains a car.If part or your
CheckedNumberstruct is anint?, you might want:Alternatively, you might want:
Otherwise, you’ll have to clarify the question further.