简体   繁体   中英

Distinct values 2d array

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM