DRAG DROP
You are developing a class named Temperature.
You need to ensure that collections of Temperature objects are sortable.
You have the following code:
Which code segments should you include in Target 1, Target 2 and Target 3 to complete the code? (To
answer, drag the appropriate code segments to the correct targets in the answer area. Each code segment
may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to
view content.)
Select and Place:
Explanation:
Note:
Target 1:
The role of IComparable is to provide a method of comparing two objects of a particular type. This is
necessary if you want to provide any ordering capability for your object.
Incorrect: The role of IComparer is to provide additional comparison mechanisms. For example, you may want
to provide ordering of your class on several fields or properties, ascending and descending order on the same
field, or both.
Target 2, Target 3:
Example:
// Implement IComparable CompareTo method – provide default sort order.
int IComparable.CompareTo(object obj)
{
car c=(car)obj;
return String.Compare(this.make,c.make);
}
How to use the IComparable and IComparer interfaces in Visual C#
https://support.microsoft.com/en-us/kb/320727
1,3,5 (not 6)
http://www.aiotestking.com/microsoft/how-should-you-complete-the-relevant-code-segment/
1,3,5
Hadi baba yaaa
ansver true
not!