c# - Find count each item in MultiDimensional List in vb.net? -
I have to store the square with 2 properties (both integers) and the list collection.
select the public class group as an integer get m_RowNo end (byvalue value value as integer) m_RowNo = value End Set End Property Private m_RowNo Form of Integer Public Property Group Return (not in) () as integer m_GroupNo End Set (ByVal value as integer) m_GroupNo = Value ending property property as private m_GroupNo integer end class
Ex:
rono group group no 1 1 2 1 4 2
How to make each item in "GroupNo" The above example is more than one time The above example 2 has only one time, then return to 'wrong'.
Row group group no 1 1 2 1 4 2 5 2
Here I need to return "right." ("No group" Value is not stable and not sorted).
How can we do this in vb.net?
so that you want to perform the operation to return true
if every code For 2 or more RowNo
are values
Note: Since you have used C # tags, I think that I would like to post the code in C # For green light is there.
Public Static Bull Hettooromoraiyeh Group (INIM Meerbell & Lt; Group Select & gt; Enumerable) {var Group = New Dictionary & lt; Int, int & gt; (); Foreign Language (Calculate the number in the group select) {int count = 0; If (groups.TryGetValue (item.GroupNo, counting out)) {groups [item groupNo] = count + 1; } Other {groups.Add (item.GroupNo, 1); }} Foreach (int count in groups.Values) {if (count & lt; = 1) {return false; True} true; }
}
or the Linq solution ...
bool result = list.GroupBy (x = & gt; x GroupNo ). Where (x = & gt; x.Count () == 1) .count ()> gt; = 2;
Comments
Post a Comment