I have a string like string strn = \"abcdefghjiklmnopqrstuvwxyz\" and want a dictionary like:
string strn = \"abcdefghjiklmnopqrstuvwxyz\"
Dictionary(){ {\'a\',0}, {
You could try something like this:
string strn = "abcdefghjiklmnopqrstuvwxyz"; Dictionary lookup = strn.ToCharArray() .Select( ( c, i ) => new KeyValuePair( c, i ) ) .ToDictionary( e => e.Key, e => e.Value );