static void Main(string[] args)
        {
            string strWhere = " and ApproveResult";
            if (strWhere.Trim().IndexOf("and") == 0)
            {
                //strWhere.Replace("and", " ");//不行
                //strWhere.Remove(strWhere.Trim().IndexOf("and"), 3);//不行
            }            Console.WriteLine(strWhere);
            Console.ReadLine();
        }
要得到ApproveResult求解!

解决方案 »

  1.   

    string strWhere = " and ApproveResult";
    strWhere.Remove("and").Trim();
      

  2.   

                                                string s;
                                               s= s.Replace("需要删除的字符串","");
      

  3.   


    strWhere.subString(strWhere.indexOf("ApproveResult"), 13);
      

  4.   

    //strWhere.Replace("and", " ");//不行
    少了附值吧!
    strWhere=strWhere.Replace("and", " ");//行
      

  5.   

                string strWhere = " and ApproveResult";
                strWhere.Replace("and", "").Trim();
      

  6.   

    strWhere.Replace("and", " ");//不行
    你没赋值
    strWhere = strWhere.Replace("and", " ");//试试
      

  7.   

    string s = "ApproveResult";
    这样最简单。
    这种问题,你不应该这么问,你要指明按照什么规则取子串,什么规则删除,比如什么字符之前的,什么字符之间的,从什么位置开始的,等等
      

  8.   

    你可真有趣
    你都没有赋值当然不行 幼手?
            static void Main(string[] args)
            {
                string strWhere = " and ApproveResult";
                if (strWhere.Trim().IndexOf("and") == 0)
                {
                    strWhere=strWhere.Replace("and", " ");//不行
                    //strWhere.Remove(strWhere.Trim().IndexOf("and"), 3);//不行
                }            Console.WriteLine(strWhere);
                Console.ReadLine();
            }