title: How can I return key value pair from a function
body: <p>I am implementing a function in C#.
  This is the function in my class.I need to get the values from the function to the form.</p>
  
  <pre><code>    public void GetRoles(string strGetRoles)
      {
          string keyObj;
          string valueObj;
          var parseTree = JsonConvert.DeserializeObject&lt;JObject&gt;(strGetRoles);
  
          foreach (var prop in parseTree.Properties())
          {
              dynamic propValue = prop.Value;
              if (prop.Name == "roles" &amp;&amp; prop.Value.HasValues)
              {
                  foreach (var proval in propValue)
                  {
                      keyObj = (string)proval.Name;
                      valueObj = (string)proval.Value;                                               
                  }
              }
              else if (prop.Name == "groups" &amp;&amp; prop.Value.HasValues)
              {
                  foreach (var proval in propValue)
                  {
                      keyObj = (string)proval.Name;
                      valueObj = (string)proval.Value;
                  }
              }
          }
   }
  </code></pre>
  
  <p>strGetRoles is the response string I get after fetching json api.
  the propvalue I get is {"roles": {"3": "Reseller","2": "Admin end user"},"groups": []}</p>
  
  <p>Now I want to call this function and get each value in an object or string array.How to return these key pair values?
  Thanks in advance!</p>