EDN Admin
Well-known member
Hello,
I have the following string:
<div style="color:Black;background-color:White; <pre>
String conn = " Provider=System.Data.SqlClient;
Metadata=c:metadata|c:MetadataSql;
Provider Connection String= <span style="color:#A31515; Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60 ";
[/code]
This string contains pairs of Keys / Values. For example:
Provider=System.Data.SqlClient;
Becomes
Key = "Provider", Value = "System.Data.SqlClient".
";" separate each Key/Value pair.
If a Value contains I want to remove those. For example:
2) Provider Connection String= Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60
Becomes
Key = "Provider Connection String"
Value = "Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60"
AND NOT:
Value = "Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60"
How can I parse such strings to a Dictionary<String, String>?
I am not sure if the string contains only 3 Key/Value pairs. I just know that is follows this rule.
Thanks,
Miguel
View the full article
I have the following string:
<div style="color:Black;background-color:White; <pre>
String conn = " Provider=System.Data.SqlClient;
Metadata=c:metadata|c:MetadataSql;
Provider Connection String= <span style="color:#A31515; Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60 ";
[/code]
This string contains pairs of Keys / Values. For example:
Provider=System.Data.SqlClient;
Becomes
Key = "Provider", Value = "System.Data.SqlClient".
";" separate each Key/Value pair.
If a Value contains I want to remove those. For example:
2) Provider Connection String= Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60
Becomes
Key = "Provider Connection String"
Value = "Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60"
AND NOT:
Value = "Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60"
How can I parse such strings to a Dictionary<String, String>?
I am not sure if the string contains only 3 Key/Value pairs. I just know that is follows this rule.
Thanks,
Miguel
View the full article