I’am trying to create a generic class that contains a list of generic type
but i want to have a default value other than null to check if an item been deleted
the list should look like this
0 TypeV (some value of TypeV)
1 null
2 null (never been used)
3 default (deleted)
4 TypeV
any ideas ?
For reference type default value will be
null(you can’t define if value was never used, or it was deleted). So your idea will not work for generic parameters of reference type. On the other hand you can’t have null values for non-reference types. So, the only option is an array of objects (it can hold both nulls and value types):And
At this point
valueswill be:But anyway you can’t define if some item was deleted, or it was added with default value.. So, your idea will work if you never add default values to array.