find if an integer exists in a list of integers

后端 未结 8 1375
执笔经年
执笔经年 2020-12-14 05:40

i have this code:

  List apps = getApps();

        List ids;

        List dropdown = apps.ConvertAll(c => new          


        
8条回答
  •  情书的邮戳
    2020-12-14 06:00

    The way you did is correct. It works fine with that code: x is true. probably you made a mistake somewhere else.

    List ints = new List( new[] {1,5,7}); // 1
    

    List intlist=new List() { 0,2,3,4,1}; // 2
    

    var i = 5;
    var x = ints.Contains(i);   // return true or false
    

提交回复
热议问题