Questions tagged [namevaluecollection]

NameValueCollection is a .Net collection of string keys and string values that can be accessed either with by key or by the index.

NameValueCollection is a .Net collection of string keys and string values that can be accessed either with by key or by the index.

References

116 questions
3
votes
1 answer

Add Duplicates keys to NameValueCollection

I have read that NameValueCollection allows for duplicate keys to be added, however this does not seem to be the case when I try to use it. My Code using (var wb = new WebClient()) { var data = new NameValueCollection(); var sourceData =…
G-Man
  • 7,232
  • 18
  • 72
  • 100
3
votes
3 answers

Modifying config sections in App.config either at runtime or install time

I have an WinForms application that is deployed using Visual Studio 2008's publish (ClickOnce) system. Within the application's app.config file I have a config section that is required by a third party component that has the form:
Godeke
  • 16,131
  • 4
  • 62
  • 86
3
votes
0 answers

ASP.NET Request.Form case-sensitivity

I have some C# code that retrieves the value of Request.Form["KeyName"], however, the code that is submitting the request is passing keyName=value. This works in our dev/stage environment, but not in production. This post Is…
joelt
  • 2,672
  • 2
  • 24
  • 32
3
votes
3 answers

Efficient searching of NameValueCollection

Is there a way to pull out keys from a NameValueCollection that pertain to a certain pattern/naming convention without having to iterate through every value in the collection?
AJM
  • 32,054
  • 48
  • 155
  • 243
2
votes
0 answers

Alternative to System.Web.HttpUtility.ParseQueryString that uses a case-insensitive comparer?

If you include a query string on the HREF of the "Launch" link on the publish.htm page that ClickOnce generates when you publish a Windows desktop application: HREF="MyWindowsApp.application?ARG1=sis&ARG2=boom&ARG3=bah" then the query…
Tim
  • 8,669
  • 31
  • 105
  • 183
2
votes
1 answer

Why does serializing a NameValueCollection incur a loss of data?

For example if we have {"Parameters":["name" : "test"]} it will be serialized to {"Parameters":["name"]}. (Using System.Text.Json) Why is that? EDIT: See this issue that brought this to my attention, and the following code that does…
SpiritBob
  • 2,355
  • 3
  • 24
  • 62
2
votes
2 answers

How to POST NULL value C#

I need to POST data from C# WinForms application into PHP page. I'm using WebClient with sample code below: using (WebClient client = new WebClient()) { NameValueCollection values = new NameValueCollection(); values.Add("menu_parent",…
Hermanto
  • 552
  • 6
  • 15
2
votes
1 answer

Why behavior of NameValueCollection is different?

NameValueCollection x = new NameValueCollection(Request.QueryString); string x1 = x.ToString(); NameValueCollection y = HttpUtility.ParseQueryString(Request.QueryString.ToString()); string y1 = y.ToString(); when I execute above code, value of x1…
yajiv
  • 2,901
  • 2
  • 15
  • 25
2
votes
1 answer

C# NameValueCollection: Should we check if key exists before we remove those?

We want to remove few keys from a NameValueCollection but we are not sure if they actually exist in it or not. If i try to remove key1 which isn't in NameValueCollection, there's no exception/side-effect: nameValues.Remove("key1"); But what is…
Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98
2
votes
1 answer

Convert DataRowCollection to NameValueCollection

I need an elegant way to convert a DataRowCollection to a NameValueCollection. note: during the conversion I need a section where I can invoke an inflector to tidy up key names
Aivan Monceller
  • 4,636
  • 10
  • 42
  • 69
2
votes
1 answer

Convert WebHeaderCollection to NameValueCollection in .Net Core

Before of dotNetCore (.Net Core), WebHeaderCollection was inherit from NameValueCollection, but not now. And I need to convert WebHeaderCollection (HttpWebResponse.Headers) to the type property NameValueCollection. Has anyone ever had to do this?
entb
  • 41
  • 3
2
votes
0 answers

NameValueCollection doesnt save to Properties.Settings

I added an entry in the Properties.Settings named strCol that is of type NameValueCollection. I am using this to save items from a listview to the settings so that when the application reboots, the ListView gets re-populated again with the items…
Dante1986
  • 58,291
  • 13
  • 39
  • 54
2
votes
2 answers

Trying to Post a Slack Message through NameValueCollection using HttpClient.PostAsync instead of WebClient

I am trying to use HttpClient to post a NameValueCollection to a specific Url. I have the code working using WebClient, but I'm trying to figure out if it is possible to do using HttpClient. Below, you will find my working code that uses WebClient:…
HaydenThrash
  • 97
  • 2
  • 9
2
votes
4 answers

How to set the length of NameValueCollection

I am a newbie in C# (not in programming). Please, what is the simplest way to decrease items count in NameValueCollection object? For example I have 13 name-value pairs in collection and I want to cut it to the first 5. Do I really have to do it in…
lyborko
  • 2,571
  • 3
  • 26
  • 54
2
votes
3 answers

c# NameValueCollection distinct values

C# code as below: NameValueCollection nvc = new NameValueCollection(); nvc.Add("color", "red"); nvc.Add("size", "s"); nvc.Add("color", "red"); nvc.Add("size", "m"); nvc.Add("color", "red"); nvc.Add("size", "l"); //blue nvc.Add("color",…
jian.wu
  • 85
  • 3