My scenario is : I have a data table where i have values in 2 rows and 3 columns as follows
Name Mon Tue Wed
Anita P A H
Sam P P H
John A H A
The bot has to check how many p are there in a row and calculate its occurrence means if it 1 time , 2 time and then return the name who has P value in their row.
How can i do this ? I tried several ways i am able to fetch name value but not total value. Please suggest on this.
Can you suggest from where to read about data table, functions used in it, its syntax as i can see you have used this enumerable here . I am not aware of all these functions. Please suggest so that i can have an idea about data tables for my future references @Yoichi
It’s LINQ expression. It mainly consists of 3 method : ToDictionary, Cast and Count.
In this case, it returns dictionary which are name as key and number of “P” as value.
ToDictionary method returns dictionary from IEnumerable<T> ( in this case it’s DataRow array). Function(r) r(0).ToString returns content of name column of the row. it will be key of dictionary. Function(r) dt.Columns.Cast(Of DataColumn).Count(Function(c) r(c).ToString="P") returns count of “P” in each column of the row.