Error message cannot have non-nullable parameter
How can I pass a List? to a method?
public int RegexAutoCode(int sID, List<Int16>? valueIDs, string text, SqlCommand cmd)
There's no such thing as a List<>?
- List
is a reference type regardless of the element type, and so is already nullable:
// This is absolutely fine
List<Int16> list = null;
If you wanted a List
of nullable Int16
values (so each element can be null or an Int16
) then you want a parameter like this:
List<Int16?> valueIDs
For Nullable<T>
to be valid, T
has to be a non-nullable value type. That's what the T : struct
constraint indicates.
Use List<Int16?>
You had the ?
in the incorrect place.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.