I have a C# function that accepts an array of IComparable
public static void sort(IComparable[] a){//...}
If I send an array of strings to this function it is accepted, but an array of ints is not accepted even though the structure Int32
extends IComparable
.
public struct Int32 : IComparable, IFormattable,
IConvertible, IComparable<int>, IEquatable<int>
First question is why it is not possible to send an array of value type to such a function.
Second question is how should I send the array of value type to the function that accepts array of IComparable
.