I have a 2D array as follows:
long[,] arr = new long[4, 4] {{ 5, 0, 0, 0 },
{ 8, 1, 1, 1 },
{ 0, 3, 0, 6 },
{ 1, 1, 1, 1 }};
How I can display distinct values form this array?
您可以使用Enumerable.Distinct
方法:
var uniqueValues = arr.Cast<long>().Distinct();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.