Search code examples
c#stringsubstringtrim

How to remove all characters from a string before a specific character


Suppose I have a string A, for example:

string A = "Hello_World";

I want to remove all characters up to (and including) the _. The exact number of characters before the _ may vary. In the above example, A == "World" after removal.


Solution

  • string A = "Hello_World";
    string str = A.Substring(A.IndexOf('_') + 1);