その中にランダムポイントを返すRectangleメソッドを持つクラスがあります。RandomPoint次のようになります。
class Rectangle {
int W,H;
Random rnd = new Random();
public Point RandomPoint() {
return new Point(rnd.NextDouble() * W, rnd.NextDouble() * H);
}
}
しかし、それIEnumerable<Point>を使用できるようになることを願っています。LINQrect.RandomPoint().Take(10)
それを簡潔に実装する方法は?