本文介绍了如何检查对象/字符串是否已经存在于列表中并且它是否存在以便如何获取它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

列表包含大量的手机号码,当我将msg发送到号码然后检查列表中存在的号码或存在然后直接发送

list is contains lots of mobile number when i send the msg to number then check the number in exists in list or exists then directly send

推荐答案

bool alreadyExists = myList.Any(x=> x.mobileNumber==mobileNoToSearch);
if (alreadyExists) {
  //Do sending stuff
}


List<string> list=new List<string>();
bool isInList=list.Contains("some string");


List<string> mobiles = new List<string>() {"077777777", "0777777778"};
if (mobiles.Contains("077777779"))
   {
   ...
   }


这篇关于如何检查对象/字符串是否已经存在于列表中并且它是否存在以便如何获取它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 11:49