Try the following
string attributes = "fill:#e2b126;stroke:#010101;stroke-width:0.3177;stroke-miterlimit:10";
var map = attributes
.Split(new []{';'}, StringSplitOptions.RemoveEmptyEntries)
.Select(x => x.Split(new []{':'}, StringSplitOptions.RemoveEmptyEntries))
.ToDictionary(p => p[0], p => p[1]);
Breakdown
The first Split
call will return an array of String
values where every entry is in the key:value
format. The following Select
call will convert every one of those entries into a string[]
where the first element is the key and the second is the value. The ToDictionary
call just expressly performs this mapping