Mapping from string "aa=bb" to Dictionary I am converting a input like :

aa=bb
Fruit1=Potato
Fruite2=Banana


Into a Dictionary, using this code.

string tmp = "\r\naa=bb\r\nFruit1=Potato\r\nFruite2=Banana";
Dictionary&lt;string, string&gt; tempValueList = new Dictionary&lt;string, string&gt;();

var lines = tmp.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
    var keyValue = line.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
    tempValueList.Add(keyValue[0],keyValue[1]);
}

tempIniObject.Key = key;
tempIniObject.ValueList = tempValueList;


This is simple, but I believe there is a mutch classier way to do it.
Why not to use regular expression? Your task can be solved with this code:

var dictionary = Regex.Matches(tmp, "(?&lt;key&gt;.+)=(?&lt;value&gt;.+)")
                      .OfType&lt;Match&gt;()
                      .Where(m =&gt; m.Success)
                      .ToDictionary(m =&gt; m.Groups["key"].Value.Trim(),
                                    m =&gt; m.Groups["value"].Value.Trim());