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
  • 48,897
  • 65
  • 188
  • 331
  • 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
  • 389
  • 4
  • 9