What are you actually trying to do in the method? It could be that you actually need C to implement IComparable, or someother interface. In which case you want something like
There is no generic constraint that matches that set of things cleanly. What is it that you actually want to do? For example, you can hack around it with runtime checks, such as a static ctor (for generic types - not so easy for generic methods)...
However; most times I see this, it is because people want one of:
to be able to check items for equality: in which case use EqualityComparer<T>.Default
to be able to compare/sort items: in which case use Comparer<T>.Default
A type is an unmanaged type if it's any of the following types:
sbyte, byte, short, ushort, int, uint, long, ulong, char, float,
double, decimal, or bool Any enum type Any pointer type Any
user-defined struct type that contains fields of unmanaged types only
and, in C# 7.3 and earlier, is not a constructed type (a type that
includes at least one type argument)
Also important quote:
Beginning with C# 7.3, you can use the unmanaged constraint to specify
that a type parameter is a non-pointer, non-nullable unmanaged type.
Beginning with C# 8.0, a constructed struct type that contains fields
of unmanaged types only is also unmanaged...