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
9
votes
3 answers

ASP.Net/C# convert NameValueCollection to IDictionary?

I’m trying to help my son upgrade a web site I built for him last year. He wants to implement Amazon Simple Pay. I’m SO close to getting it, but have an error that I don’t know how to address. It’s an ASP.Net site done in C#. I am an untrained…
DJGray
  • 504
  • 8
  • 26
8
votes
2 answers

sorting a namevaluecollection

How do I sort a namevaluecollection in alphabetical order? Do I have to cast it to another list first like the sorted list or Ilist or something? If then how do I do that? right now I have all my string in the the namevalucollection variable.
zack
  • 7,115
  • 14
  • 53
  • 63
8
votes
0 answers

ConfigurationManager.AppSettings generates compile time error on .Net Standard 1.5

I'm using .Net Standard 1.5 and want to read some values out of my config. However the following line ConfigurationManager.AppSettings["Foo"] gives me the following compile time error: CS7069 Reference to type 'NameValueCollection' claims it is…
6
votes
2 answers

Is there any easy way to sort NameValueCollection on the basis of key in C#?

I am looking for an easy way to sort NameValueCollection on the basis of key - it should not be a performance heavy though.
Bluish
6
votes
4 answers

XML serialization of a collection in C#

I have two classes as follows: public class Info { [XmlAttribute] public string language; public int version; public Book book; public Info() { } public Info(string l, int v, string author, int…
Archie
  • 2,564
  • 8
  • 39
  • 50
5
votes
1 answer

Returning dynamic key value collection in ASP.NET Web API

I am developing an ASP.Net Web API project. In my project, I am trying to return JSON from action in this format. { "Apple": null, "Microsoft": null, "Google": 'http://placehold.it/250x250' } As you can see in the JSON, it is key value pairs.…
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
5
votes
2 answers

How to get all values as a single string from NameValueCollection?

How to key all values from NameValueCollection as a single string, Now I am using following method to get it: public static string GetAllReasons(NameValueCollection valueCollection) { string _allValues = string.Empty; foreach (var key in…
Ankush Madankar
  • 3,689
  • 4
  • 40
  • 74
5
votes
6 answers

Remove a single value from a NameValueCollection

My data source could have duplicate keys with values. typeA : 1 typeB : 2 typeA : 11 I chose to use NameValueCollection as it enables entering duplicate keys. I want to remove specific key\value pair from the collection, but…
Ayman
  • 51
  • 1
  • 3
4
votes
4 answers

NameValueCollection key without value

I have a NameValueCollection variable queryDict. Some of the keys have no values. However I would like to go through all keys, even if they have no values associated to them. Using this, I get null instead of the key name if value is empty: foreach…
Cher
  • 2,789
  • 10
  • 37
  • 64
4
votes
1 answer

how to initialize NameValueCollection with inner NameValueCollection

After I tried to initialize a NameValueCollection with an inner NameValueCollection, the c# compiler says that has to be NameValueCollection(string,string). As I thought when I call the Add function when I initialize like this. void…
Max
  • 1,203
  • 1
  • 14
  • 28
4
votes
2 answers

How to Modify HTTP Header of a request using C#?

I was trying to modify a HTTP Header using C#. I tried to manipulate the Request.Headers on Page preinit event. But when i try to set anything to the Headers, i get PlatformNotSupportedException. Since We can not set a new NameValueCollection to…
Amit
  • 25,106
  • 25
  • 75
  • 116
4
votes
6 answers

AppSettings fallback/default value?

ASP.NET For each appSetting I use, I want to specify a value that will be returned if the specified key isn't found in the appSettings. I was about to create a class to manage this, but I'm thinking this functionality is probably already in the…
lance
  • 16,092
  • 19
  • 77
  • 136
3
votes
3 answers

What is the best way to have a page read values posted to it from another page?

What is the best way to have a page read values posted from another page? I have something that works, but it seems rather sloppy. I'm working on a multi-page form with the first page using PostBackUrl to go to the second. Within page 1 is content…
someguy
  • 41
  • 3
3
votes
1 answer

Can a freemarker interpolation contain an interpolation?

Let's say I have Freemarker variable A that contains the name of another variable on the hash tree, say. "B." I'd like to use a to read the value of B so, for example, if B contained "C" I could tell Freemarker to output C using A: ${${A}} should…
Jake
  • 462
  • 1
  • 9
  • 19
3
votes
1 answer

Can't resolve NameValueCollection with Autofac

I am using Autofac 2.1.12 to handle my dependency injection, and am having trouble with one specific issue. I can't seem to resolve a NameValueCollection dependency. Consider the following code snippet: class Foo { public Foo(NameValueCollection…
Matthew King
  • 5,114
  • 4
  • 36
  • 50