String.IndexOf 方法 (String) [C#]请参见 String 类 | String 成员 | System 命名空间 | String.IndexOf 重载列表 | Int32 | CultureInfo | IndexOfAny | LastIndexOf | LastIndexOfAny | String 成员(Visual J# 语法) 要求 平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版 - Windows CE .NET, 公共语言基础结构 (CLI) 标准 语言 C#C++JScriptVisual Basic全部显示 报告指定的 String 在此实例中的第一个匹配项的索引。[C#] public int IndexOf( string value ); 参数 value 要查找的 String。 返回值 如果找到该字符,则为 value 的索引位置;如果未找到该字符,则为 -1。如果 value 为 Empty,则返回值为 0。
if InStr(inputstring,"a")>0 Then Response.Write("有a") else Response.write("没有a") end if
String 类 | String 成员 | System 命名空间 | String.IndexOf 重载列表 | Int32 | CultureInfo | IndexOfAny | LastIndexOf | LastIndexOfAny | String 成员(Visual J# 语法)
要求
平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版 - Windows CE .NET, 公共语言基础结构 (CLI) 标准
语言
C#C++JScriptVisual Basic全部显示
报告指定的 String 在此实例中的第一个匹配项的索引。[C#]
public int IndexOf(
string value
);
参数
value
要查找的 String。
返回值
如果找到该字符,则为 value 的索引位置;如果未找到该字符,则为 -1。如果 value 为 Empty,则返回值为 0。
if InStr(inputstring,"a")>0 Then
Response.Write("有a")
else
Response.write("没有a")
end if
我用indexof()报错
if(strMessage.IndexOf("a") > 0)
{
//有a
}
else
{
//没有a
}