c#里面用LastIndexOf得到字符串中某子字符串最后一次出现的位置,但是字符串中有"\",程序会报错,请教各位高手,如何处理!谢谢!

解决方案 »

  1.   

    Me.Response.Write(Me.TextBox1.Text.LastIndexOf("\4").ToString()) '测试 "abc\def\ab2\4567"没有错
      

  2.   

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string s = @"abc\edf\abcg";
                Console.WriteLine(s.LastIndexOf("abc"));
                Console.WriteLine(s.LastIndexOf(@"\"));
            }
        }
    }
    输出
    8
    7
    没有错啊
    提问把题目描述的越具体 别人解答越快