title: How to Check All Values in Dictionary is same in C#?
body: <p>I have a Dictionary, I want to write a method to check whether all values are same in this Dictionary.
  Dictionary Type: </p>
  
  <pre><code>Dictionary&lt;string, List&lt;string&gt;&gt;
  </code></pre>
  
  <p>List {1,2,3}`and {2,1,3} are same in my case.</p>
  
  <p>I have done this previously for simple datatype values, but I can not find logic for new requirement, please help me.
  For simple values:
      MyDict.GroupBy(x => x.Value).Where(x => x.Count() > 1)</p>
  
  <p>I have also written a Generic Method to compare two datatypes in this way.</p>
  
  <pre><code>// 1
              // Require that the counts are equal
              if (a.Count != b.Count)
              {
                  return false;
              }
              // 2
              // Initialize new Dictionary of the type
              Dictionary&lt;T, int&gt; d = new Dictionary&lt;T, int&gt;();
              // 3
              // Add each key's frequency from collection A to the Dictionary
              foreach (T item in a)
              {
                  int c;
                  if (d.TryGetValue(item, out c))
                  {
                      d[item] = c + 1;
                  }
                  else
                  {
                      d.Add(item, 1);
                  }
              }
              // 4
              // Add each key's frequency from collection B to the Dictionary
              // Return early if we detect a mismatch
              foreach (T item in b)
              {
                  int c;
                  if (d.TryGetValue(item, out c))
                  {
                      if (c == 0)
                      {
                          return false;
                      }
                      else
                      {
                          d[item] = c - 1;
                      }
                  }
                  else
                  {
                      // Not in dictionary
                      return false;
                  }
              }
              // 5
              // Verify that all frequencies are zero
              foreach (int v in d.Values)
              {
                  if (v != 0)
                  {
                      return false;
                  }
              }
              // 6
              // We know the collections are equal
              return true;
  </code></pre>