using System.Collections;
public class Temperature : IComparable
protected double temperatureF;
public int CompareTo(object obj) {
if (obj == null) return 1;
Temperature otherTemperature = obj as Temperature;
if (otherTemperature != null)
return this.temperatureF.CompareTo(otherTemperature.temperatureF);
throw new ArgumentException("Object is not a Temperature");
return this.temperatureF;
this.temperatureF = value;
return (this.temperatureF - 32) * (5.0/9);
this.temperatureF = (value * 9.0/5) + 32;
public class CompareTemperatures
public static void Main()
ArrayList temperatures = new ArrayList();
Random rnd = new Random();
foreach (Temperature temp in temperatures)
Console.WriteLine(temp.Fahrenheit);