Posted By

vovik on 11/20/11


Tagged


Versions (?)

NameValueCollection.Get()


 / Published in: C#
 

  1. // System.Collections.Specialized.NameValueCollection
  2. public virtual string Get(string name)
  3. {
  4. ArrayList list = (ArrayList)base.BaseGet(name);
  5. return NameValueCollection.GetAsOneString(list);
  6. }
  7.  
  8. private static string GetAsOneString(ArrayList list)
  9. {
  10. int num = (list != null) ? list.Count : 0;
  11. if (num == 1)
  12. {
  13. return (string)list[0];
  14. }
  15. if (num > 1)
  16. {
  17. StringBuilder stringBuilder = new StringBuilder((string)list[0]);
  18. for (int i = 1; i < num; i++)
  19. {
  20. stringBuilder.Append(',');
  21. stringBuilder.Append((string)list[i]);
  22. }
  23. return stringBuilder.ToString();
  24. }
  25. return null;
  26. }
  27.  
  28. // System.Collections.Specialized.NameObjectCollectionBase
  29. private Hashtable _entriesTable;
  30.  
  31. protected object BaseGet(string name)
  32. {
  33. NameObjectCollectionBase.NameObjectEntry nameObjectEntry = this.FindEntry(name);
  34. if (nameObjectEntry == null)
  35. {
  36. return null;
  37. }
  38. return nameObjectEntry.Value;
  39. }
  40.  
  41. private NameObjectCollectionBase.NameObjectEntry FindEntry(string key)
  42. {
  43. if (key != null)
  44. {
  45. return (NameObjectCollectionBase.NameObjectEntry)this._entriesTable[key];
  46. }
  47. return this._nullKeyEntry;
  48. }

Report this snippet  

You need to login to post a comment.