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?

NibblyPig
  • 51,118
  • 72
  • 200
  • 356
  • 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 – Stefan Mar 19 '19 at 15:00

1 Answers1

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(';');
YouneS
  • 390
  • 4
  • 10