CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 27

Threaded View

  1. #17
    Join Date
    Jul 2006
    Posts
    297

    Re: construct array out of string

    Quote Originally Posted by BigEd781 View Post
    Well, that is just the method to get the value. You can use it to create a dictionary.
    Would be counter productive to create a dictionary like this because he would need to know the all the values ahead of time. I suppose you could use the dictionary as a caching mechanism though and just save the result in a dictionary and only resort to the GetValue() if no entry is in the dictionary... Something like this.

    Code:
    public String GetCachedValue(String name)
    {
          if(!dictionary.ContainsKey(name))
              dictionary[name] = GetValue(name);
          return dictionary[name];
    }
    Quote Originally Posted by memeloo View Post
    and why not something like this?
    In the original problem it was stated that the fields present in the string would be different depending on what he was trying to do. So we needed a solution that was a little more generic and worked with any string of name/value pairs.
    Last edited by monalin; July 16th, 2009 at 01:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured