如何判断一个字符串变量是否包含另一个子字符串 如 string a="abcde"; string b="cd"; 判断 a是否包含b 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if(a.IndexOf(b)>0) MessageBox.Show("a包含了b"); 例使用 InStr 函数返回一个字符串在另一个字符串中的第一个匹配项的位置。Dim SearchString, SearchChar As StringDim MyPos As IntegerSearchString ="XXpXXpXXPXXP" ' String to search in.SearchChar = "P" ' Search for "P".' A textual comparison starting at position 4. Returns 6.MyPos = InStr(4, SearchString, SearchChar, CompareMethod.Text) ' A binary comparison starting at position 1. Returns 9.MyPos = InStr(1, SearchString, SearchChar, CompareMethod.Binary)' Comparison is binary by default (last argument is omitted).MyPos = InStr(SearchString, SearchChar) ' Returns 9.MyPos = InStr(1, SearchString, "W") ' Returns 0. if(a.IndexOf(b)!=-1) console.WriteLine("找到了!"); string a="abcde"; string b="cd"; if(a.IndexOf(b)>=0) MessageBox.Show("a包含b"); else MessageBox.Show("a不包含b"); .dll文件为什么会被删除? componentone 的C1中有皮肤控件吗? c#怎么实现图片的拖动与缩放 请教 c#怎么创建非模态对话框? [牢骚50] 技术重要还是文凭重要? 急急!!盼求指教 请高手指点:用owc实现的柱状图能否将数据表一同显示? 请问一个简单的问题? 要做一个像163一样的邮件系统,谁有这方面的资料,谢谢 c#对dbf进行删除的问题 请问"QQ验证码识别源代码(C#/NET1.1)"怎么样调用
MessageBox.Show("a包含了b");
Dim MyPos As IntegerSearchString ="XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".' A textual comparison starting at position 4. Returns 6.
MyPos = InStr(4, SearchString, SearchChar, CompareMethod.Text) ' A binary comparison starting at position 1. Returns 9.
MyPos = InStr(1, SearchString, SearchChar, CompareMethod.Binary)' Comparison is binary by default (last argument is omitted).
MyPos = InStr(SearchString, SearchChar) ' Returns 9.MyPos = InStr(1, SearchString, "W") ' Returns 0.
console.WriteLine("找到了!");
string b="cd";
if(a.IndexOf(b)>=0)
MessageBox.Show("a包含b");
else
MessageBox.Show("a不包含b");