---
title: "Convert query string to key-value pair"  
description: "Convert query string to key-value pair"  
author: "Anonymous User"  
published: 2014-09-03  
updated: 2014-09-03  
canonical: https://www.mindstick.com/forum/2243/convert-query-string-to-key-value-pair  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Convert query string to key-value pair

If I have a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) like so:

"[Name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide)=Irwin&[amp](https://www.mindstick.com/forum/156207/what-is-amp);[Home](https://www.mindstick.com/articles/126322/how-to-keep-your-home-safe-while-traveling)=[Caribbean](https://answers.mindstick.com/qa/47124/how-is-the-movie-pirates-of-the-caribbean-on-stranger-tides)&Preference=Coffee"

is there a [method in C#](https://www.mindstick.com/forum/33924/can-this-be-used-within-a-static-method-in-c-sharp) that can [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) that to a key-[value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) pair similar to Request.QueryString?

## Replies

### Reply by Sumit Kesarwani

Hi, \

You can also use the ToDictionary() [method](https://www.mindstick.com/forum/166/webservice-method):

```
var input ="Name=Irwin&Home=Caribbean&Preference=Coffee";var items = input.Split(new[] { '&' });var dict = items.Select(item => item.Split(new[]
{'='})).ToDictionary(pair => pair[0], pair => pair[1]);
```


---

Original Source: https://www.mindstick.com/forum/2243/convert-query-string-to-key-value-pair

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
