[英]Get most used byte array in a byte array in c#?
How can I get the most used byte array from another bytearray?如何从另一个字节数组中获取最常用的字节数组? Is there is simple way to do this?
有没有简单的方法可以做到这一点?
So for example:例如:
the input byte array: 41, 4, 5, 42,4,5,42,4,5,42,2输入字节数组:41, 4, 5, 42,4,5,42,4,5,42,2
And then the return: 4, 5, 42然后返回:4, 5, 42
Thanks in advance.提前致谢。
var grouped = prod.ToLookup(x => x);
var maxRepetitions = grouped.Max(x => x.Count());
var allItemsWithEqualMax = grouped.Where(x => x.Count() == maxRepetitions)
.Select(x => x.Key).ToList();
Creds: https://stackoverflow.com/a/15184669/496680信用: https ://stackoverflow.com/a/15184669/496680
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.