T
Tony Johansson
Hi!
This is just for understanding I know about generics.
If I have for example this ArrayList
ArrayList list = new ArrayList();
and add some int's(Int32) to this list and then use the sort method like
this
list.Sort();
then the default Comparer class is used which is the default implementation
of the IComparer interface.
Question number 1:
Now to my question is there any methods or property in the int32 structure
that is used when I use the Sort method
in the ArrayList ?
I mean if there are any requirements on the int's structure when you use the
Comparer class that implement the Compare method.
Here is the header for the struct definition for int32 and as I can see here
is there no interface that is used
when I do list.Sort using the Comparer class.
public struct Int32 : IComparable, IFormattable,
IConvertible, IComparable<int>, IEquatable<int>
{...}
Question number 2:
So as I understand this the Sort method in ArrayList just call the method
Compare in the Comparer class
Comparer.Compare(object x, object y )
So the actual datatype int's in the ArrayList is passed as argument to the
Compare method in the Comparer class.
//Tony
This is just for understanding I know about generics.
If I have for example this ArrayList
ArrayList list = new ArrayList();
and add some int's(Int32) to this list and then use the sort method like
this
list.Sort();
then the default Comparer class is used which is the default implementation
of the IComparer interface.
Question number 1:
Now to my question is there any methods or property in the int32 structure
that is used when I use the Sort method
in the ArrayList ?
I mean if there are any requirements on the int's structure when you use the
Comparer class that implement the Compare method.
Here is the header for the struct definition for int32 and as I can see here
is there no interface that is used
when I do list.Sort using the Comparer class.
public struct Int32 : IComparable, IFormattable,
IConvertible, IComparable<int>, IEquatable<int>
{...}
Question number 2:
So as I understand this the Sort method in ArrayList just call the method
Compare in the Comparer class
Comparer.Compare(object x, object y )
So the actual datatype int's in the ArrayList is passed as argument to the
Compare method in the Comparer class.
//Tony