I'm using c# and I need to replace a string with other data. This is the string, the servername, user1 and 380kj data and length can change.
"Data Source=servername;User ID=user1;Password=380kj"
I want this result:
"Data Source=servername;User ID=XXXXX;Password=XXXXX"
I have done an IndexOf on User ID and Password but I don't know how to get the exact count to use the remove function so I can then insert the XXXXX into the string.
int index = SaleDatabase.ConnectionString.IndexOf("User ID=");
int index2 = SaleDatabase.ConnectionString.IndexOf(";Password");
What can I do?
thanks...
string.ReplaceorRegex.Replace. Don't mess around with IndexOf nonsense as it makes code needlessly complicated.