assuming that delimiters cannot appear in keys or values:
var dict = str.split(';') .select(s => s.split(':')) .todictionary(a => a.trim(), a => a.trim()));
this is not the fastest way to do it, but it is the simplest.
you could also use a regex:
static readonly regex parser = new regex(@"([^:]):([^;])"); var dict = parser.getmatches(str) .cast<match>() .todictionary(m => m.groups.value.trim(), m => m.groups.value.trim() );
- Create a dictionary<string,string> from a semicolon separated string using linq
- Object from comma separated string using linq
- Create a string collection from CheckedListBox.CheckedItems using LINQ
- Using Linq to return a Comma separated string
- Create a list of one object type from a list of another using Linq
- Using LINQ to parse the numbers from a string
- Create Items from 3 collections using Linq
- How to remove characters from a string using LINQ
- Split a separated string into hierarchy using c# and linq
- using LINQ how can i concatenate string properties from itesm in a collection
- convert comma separated string to list using linq
- Extract data from a XML string using linq vs xmlDocument
- Using LINQ to delete an element from a ObservableCollection Source
- How to create a comma delimited string from distinct list of values using LINQ?
- Access property in lambda expression from string when using LINQ
- Create List of Tuples from List using LINQ
- Using LINQ how do I create a List of one particular field of an entity from a collection entities
- Using LINQ to create pairs from two different list where the entries have same attribute
- Using LINQ to strip a suffix from a string if it contains a suffix in a list?
- I am trying create a new list of users from a list of users who have not created an additional object with a certain property using LINQ
- Make a List of String array from a List of String using LINQ
- Create Mapping from Dictionary of Lists using Linq
- How to Select the Token and Index from a Comma Separated String in Linq
- creating Linq to sqlite dbml from DbLinq source code
- Using LINQ lambda to replace characters from array in string
- Extract list of objects from a string using linq
- Select a matching string randomly from a list using LINQ
- LINQ to SQL create query from string
- To determine if one of the Strings from a list contains the initial part of a specified string using LINQ
- Using C# and Linq to create an array containing unique items from two input arrays
More Query from same tag
- Is it possible to accelerate (dynamic) LINQ queries using GPU?
- Counting cells in a column with EPPlus
- XML Literal with Linq statement
- How to convert type int to int?
- Asp.net MVC4: Custom paging
- Iterate over list of lists by the X coordinate?
- IEnumerable<List<DataRow>> does not contain a definition for ToList()
- How to Join two dictionary collections linq query
- Sort and allocate objects in a list
- Appending to Query if not null
- Invalid initializer member declarator when projecting into complex types
- Compare 2 List of object's boolean property and return the boolean value true if they matches
- Conditional count group by in LINQ C#
- Solution to rank positions in my LIST?
- Linq - how to filter dataset based on data in another table?
- How to check for nulls in a deep lambda expression?
- Load page before content (data from database)
- How can I achieve that application remains responsive, while threads work in the background?
- Entity Framework group by age range starting at zero
- Update the property of list items without "loop" and "if"
- Select from List<object> and assign to new List<object>
- Linq to XML Queries
- How do I group a list using Linq
- Linq parameter error
- two-dimensional array to an array in visual basic
- mvc 4 IEnumerable checking if its null
- How to match data from two data tables have single row using LINQ or C# other way
- Difference between “Equals” and “SequenceEqual”?
- LINQ - SQL Display data in html table
- C# - convert anonymous type to observablecollection