I've got a list of strings like this.
MainItem.Item1.AssetID_0 MainItem .Item1.AssetID_1 MainItem.Item1.AssetID_2 MainItem.Item1.AssetID_3 MainItem.Item1.AssetID_4 MainItem.Item1.AssetID_5 MainItem.Item2.AssetID_1 MainItem.Item2.AssetID_2 MainItem.Item2.AssetID_3 MainItem.Item2.AssetID_4 MainItem.Item2.AssetID_5
two separate lists of me this list should based on different "MainItem.Item". Will answer
MainItem.Item1.AssetID_0 MainItem.Item1.AssetID_1 MainItem.Item1.AssetID_2 MainItem.Item1.AssetID_3 MainItem.Item1.AssetID_4 MainItem.Item1.AssetID_5
and
MainItem.Item2.AssetID_1 MainItem.Item2.AssetID_2 MainItem.Item2.AssetID_3 MainItem.Item2.AssetID_4 MainItem.Item2.AssetID_5
This is what I have tried so far. But it is not returning the desired output
var resultsLists = mainList.Select (GetPathFromKey). Undoubtedly (); Public static string [] Splitkey (string keyfroiding) {Return keyfroiding. Split ('.'); } Public Stabilized String GetPathFromKey (string keyfroiding) {string [] splittedStrings = Splitkey (keyFromReading); Return string.joint (".", Split strings [0], split strings [1]); }
You can use ....
From the list & lt; String & gt; & Lt; allLists = wire .Select (str = & gt; new {str, token = str.Split () '.'}) .Where (x = & gt; x.token.Length & gt; = 2) .GroupBy (X = & gt; string.Concat (x.token.Take (2))) .Select (g = & gt; g.Select (X = & gt; x.str) .ToList ()) .ToList ();
This list is from the list & lt; String & gt;
The first item contains 6 lines with 1 and the other has 5 lines with ITEM2,
No comments:
Post a Comment