I have a string which I apply some LINQ methods. After applying a Replace, I would like to add a '/' character at the beginning of the resulting string if and only if it does not exists yet.
For example:
string myString = "this is a test";
string newString = myString.Replace(" " , string.Empty).AddCharacterAtBeginingIfItDoesNotExists('/');
So the resulting newString should be:
"/thisisatest"
If character '/' already exists, it is not needed to add it. For example:
string myString = "/this is a test";
string newString = myString.Replace(" " , string.Empty).AddCharacterAtBeginingIfItDoesNotExists('/');
So the resulting newString should be:
"/thisisatest"