using System.Collections;
using System.Collections.Generic;
double Thoughness { get; set; }
class Magnet : IComparable
public int CompareTo(object obj)
Magnet m = obj as Magnet;
return this.Power.CompareTo(m.Power);
class Iron : IThoughness, IComparable
public double Thoughness { get; set; }
public int CompareTo(object obj)
if(this.Thoughness > ir.Thoughness)
else if(this.Thoughness < ir.Thoughness)
public MagnetBox(params int[] mPower)
magnets = new Magnet[mPower.Length];
for(int i = 0; i < mPower.Length; ++i)
magnets[i] = new Magnet();
magnets[i].Power = mPower[i];
public int SumPower { get { return sumPower; } }
private Magnet[] magnets;
public Magnet[] Magnets { get { return magnets; } }
public IEnumerator GetEnumerator()
foreach(Magnet m in magnets)
public static void Main()
List<Iron> iron = new List<Iron>(){new Iron(2), new Iron(2.5), new Iron(0.6), new Iron(1.54),
new Iron(9.58), new Iron(7.14), new Iron(3.63), new Iron(1.76),};
Console.WriteLine(ir.Thoughness);
Console.WriteLine(ir.Thoughness);
MagnetBox mb = new MagnetBox(2,4,9,7,3);
Console.WriteLine(mg.Power);