find min value

zhshqzyc
zhshqzyc used Ask the Experts™
on
HI

I have an list(array)
1  0.01
2  0.04
3  0.04
5  0.1

Open in new window

I want to find the string which has the minimum value which is 0.01(here example)
The result is
1 0.01 

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
using System.Linq;

var values = new List<double>(){ .01, .04, .04, .1 };
Console.WriteLine(values.Min()); //.01

Open in new window

Author

Commented:
Please consider 1,2,3,5 etc.
1 space 0.01 is a string
Francis OmorutoInfrastructure and Database Design Consultant

Commented:
You have two entities in each string. How is the first entity to be treated?
Should it be ignored?
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Author

Commented:
No, I want to get both of them together. I think linq can do it but I am not strong on it.
It could be likely
select data 
let element = data.split(' ')[1]
where element.min()

Open in new window

Commented:
I'm not sure what you mean by, "I want to get both of them together."

You're pretty close with your last comment:

var values = new List<string>(){ "1 .01", "2 .04", "3 .04", "5 .1" };
Console.WriteLine(values.Select(s => s.Split(' ')[1]).Min()); //.01

Open in new window

Author

Commented:
Does it return "0.01" or "1 0.01"?
I want the later.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial