0

I want to slice that string conStr = "server='MyServer';DataBase='MySQL';username='myAdmin';password='myPass';"

indexOf(;)

and parse the values into an object{string server, string DataBase,etc} how should i do that?

1
  • In this specific case you should use the SqlConnectionStringBuilder as @Rango wrote. But in general just use string.Split(';') to split the string in tokens Commented Mar 19, 2019 at 15:00

1 Answer 1

2

You can use Split function to split your string into tokens

string phrase = "server='MyServer';DataBase='MySQL';username='myAdmin';password='myPass';";
string[] words = phrase.Split(';');
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.