Fastest way to detect duplicate numbers on array vb.net 2005

前端 未结 9 1426
轮回少年
轮回少年 2021-01-20 17:31

I have this project that let user inputs 5 different numbers from 1 to 50. But I want to validate it before saving to DB that i will be 5 unique numbers. What\'s the best an

9条回答
  •  一生所求
    2021-01-20 18:19

    Here's an alternate solution, not sure how it compares, efficiency wise, to the other solutions, but it seems to work (uses LINQ).

    Dim numbers As List = getListOfNumbers()
    Dim allUnique As Boolean = numbers.Distinct().Count() = numbers.Count()
    

提交回复
热议问题