Test if all values in a list are unique

后端 未结 8 1972
温柔的废话
温柔的废话 2020-12-03 09:22

I have a small list of bytes and I want to test that they\'re all different values. For instance, I have this:

List theList = new List

        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 09:55

    bool isUnique = theList.Distinct().Count() == theList.Count();
    

提交回复
热议问题