首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么判断某一文本中存在某一字符串

2012-04-20 
如何判断某一文本中存在某一字符串例如我想查1.txt文本中是否存在steven 这个字符串,请问代码怎样写[解

如何判断某一文本中存在某一字符串
例如我想查1.txt文本中是否存在"steven" 这个字符串,请问代码怎样写

[解决办法]
读出来

C# code
 string strfromtxt = File.ReadAllText(@"C:\1.txt", Encoding.GetEncoding("GB2312"));            if (strfromtxt.Contains("steven"))            {                MessageBox.Show("存在steven");            }            else            {                MessageBox.Show("不存在steven");            } 

热点排行