I have points struct array:
Point[] arr = samples.pointsArray;
I need to retrieve from this array point where the X is the biggest number.
Point maxX= (some logic);
Any idea how I can implement this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
OrderByandFirstLINQ operators:Point minX = arr.OrderBy(p => p.X).First();Point maxX = arr.OrderByDescending(p => p.X).First();or
Point maxX = arr.OrderBy(p => p.X).Last();Alternative solution (without using
OrderBy):How to get the Point with minimal X from an array of Points without using OrderBy?