In the following chunk of code:
public struct Nullable<T> : IFormattable, IComparable, INullable,
IComparable<Nullable<T>>
{
// ...
}
I understand that this struct is implementing these interfaces but I do not get the IComparable<Nullable<T>>
part. What it means?
It means that you can compare any Nullable<T>
with another instance of Nullable<T>
(for the same T
) in a strongly typed way. It will have a method like this:
public int CompareTo(Nullable<T> other)
Note that the normal Nullable<T>
struct doesn't have any of these interfaces. Personally I think it would be somewhat confusing to have another Nullable<T>
struct kicking around the place... I would suggest that if it's in your power to do so, you rename this struct to something else. It's also pretty strange that T
isn't constrained using the where T: struct
constraint...
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.