KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to remove the first (and ONLY the first) occurrence of a string from another string. Here is an example replacing the string "\\Iteration" . This: ProjectName\\Iteration\\Release1\\Iteration1 would become this: ProjectName\\Release1\\Iteration1 Here some code that does this: const string removeString = "\\Iteration"; int index = sourceString.IndexOf(removeString); int length = removeString.Length; String startOfString = sourceString.Substring(0, index); String endOfString = sourceString.Substring(index + length); String cleanPath = startOfString + endOfString; That seems like a lot of code. So my question is this: Is there a cleaner/more readable/more concise way to do this?
Tags (comma-separated)
Save Edits
Cancel