TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Farhan Shariff
NA
933
242.2k
Finding maximum and minimum Value column wise in datatable
May 22 2014 11:32 AM
I have two tables I want to compare them using Par Name column(here rows are compare with columns of table5) and find lowest and highest values
table 1
Par Name
SKIP
Lowest value
Highest
Value
D_Id
0
Split
0
Val_2
0
Val_1
0
Val_4
0
table5
D_ID
Split
Val_1
Val_2
Val_4
N_01
Ret
-0.13672
-0.56202
-0.4211
N_92
Ret
-0.13767
-0.13911
-0.56752
N_03
Stress
-0.13711
-0.42072
-0.41932
N_98
Stress
-0.6132
-0.41979
-0.42025
N_56
Stress
-0.42026
-0.41955
-0.1367
for (int q = 2; q < table1.Rows.Count; q++)
{
string colVal = table1.Rows[q]["Par Name"].ToString();
if(table5.Columns.Contains(colVal))
{
// Error : Specified cast is not valid
table1.Rows[q]["Lowest value"] = table5.AsEnumerable().Min(r => r.Field<double>(colVal));
table1.Rows[q]["Highest Value"] = table5.AsEnumerable().Max(r => r.Field<double>(colVal));
}
}
output table
Par Name
SKIP
Lowest value
Highest
Value
D_Id
0
Split
0
Val_2
0
-0.56202
-0.13911
Val_1
0
-0.6132
-0.13672
Val_4
0
-0.56752
-0.1367
Reply
Answers (
4
)
text file to access database file using c#
c# webrowser act on button click with getelementbyid