string str = "Placeholder#ErrorMessege#Placeholder";
请问如何截取其中的"ErrorMessege"?

解决方案 »

  1.   

    string[] message=str.Split('#');
    string showMessage= message[1];
    这个showMessage就是你要的
      

  2.   

    或string txt="Placeholder#ErrorMessege#Placeholder";
    string[] sArray = txt.Split('#');
    foreach (string t in sArray)
    {
       Console.WriteLine(t);
    }
    Console.ReadLine();
      

  3.   

    string str = "Placeholder#ErrorMessege#Placeholder";
    int firstIndex = str.IndexOf("#");
    int secondIndex = str.IndexOf("#", firstIndex + 1);
    string ret = str.Substring(firstIndex + 1, secondIndex - firstIndex - 1);