string   tagStr ="type =";// (string)curTN.Tag; 
int      numInt;
if (tagStr != "")
{
numInt = tagStr.IndexOf("type");
if ( numInt == 1)
{
tagStr.IndexOf("type");
}
}这段代码没有问题,我试了。

解决方案 »

  1.   

    是不是在程序的开头没有引入命名空间?using system
      

  2.   

    系统命名空间肯定有了.只是我在 debug 跟踪的时候老是得到 -1 
    于是我把  tagStr.IndexOf("type") 拷贝到监视窗口,提示 错误:“tagStr.IndexOf”不存在
    理由我说不清楚
      

  3.   

    我看了觉得没问题,试了发现也没问题,但是IndexOf的结果是0不是1哦。
    另外NHU老兄你在if里面写了个tagStr.IndexOf("type");干吗啊??private void button1_Click(object sender, System.EventArgs e)
    {
    string   tagStr ="type =";// (string)curTN.Tag; 
    int      numInt;
    if (tagStr != "")
    {
    numInt = tagStr.IndexOf("type");
    if ( numInt == 0)
    {
    MessageBox.Show(numInt.ToString());
    }
    }
    }