I have a rectangle array defined like this
Rectangle[] recArray = new Rectangle[100];
I need a way to filter out rectangles that have 1:2 aspect ratio like the one below
Please advice me the best way to do this.
You can use a linq query like this:
var result = recArray.Where(x => x.Height / x.Width == 2).ToList();
The result is a List<Rectangle>
which you can draw them or do whatever you need with them.
If you need an Array
instead of the List
use .ToArray()
method instead of ToList()
.
Also don't forget to add using System.Linq;