在字符串数组中查找字符串 [英] Find a string in string array

查看:349
本文介绍了在字符串数组中查找字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串数组,我得到10个字符串,我想找到一个特定的字符串,并根据我必须做的事情。但是如何查询字符串数组??

I am having a string array and i am getting 10 strings into it and i want to find a specific string and based on that i have to do something.But how to query a string array??

推荐答案

检查此如何搜索字符串数组中的字符串 [ ^ ]


查看链接



http://stackoverflow.com/questions/264962/how-to-search-a-string-in-string-数组 [ ^ ]



http://msdn.microsoft.com/ en-us / library / ysey5bxa(v = vs.90).aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/aa287730(v = vs.71).aspx [ ^ ]
view link

http://stackoverflow.com/questions/264962/how-to-search-a-string-in-string-array[^]

http://msdn.microsoft.com/en-us/library/ysey5bxa(v=vs.90).aspx[^]
http://msdn.microsoft.com/en-us/library/aa287730(v=vs.71).aspx[^]


您可以使用LINQ来搜索它。如下例所示:

You could use LINQ to search on it. Like in the next example:
var query = from item in yourStringArray
             where item.Contains("ana") 
             select item; // First you should create the LINQ query;
string firstResult = query.FirstOrDefault(); //Then get the first result from the query!


这篇关于在字符串数组中查找字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆