title: get all service contract method names
body: <p>Am consuming the WCF service from WPF and I want to list all the method names from service.</p>
  
  <p>I have tried with two solutions,
  1.</p>
  
  <pre><code>MethodInfo[] methods = typeof(TypeOfTheService).GetMethods();
  foreach (var method in methods)
  {
      string methodName = method.Name;
  }
  </code></pre>
  
  <p>It lists all functions but it include some other functions also like "to string","open","abort" etc.</p>
  
  <hr>
  
  <p>2.</p>
  
  <pre><code>MethodInfo[] methods = typeof(ITimeService).GetMethods();
  
              foreach (var method in methods)
              {
                  if (((System.Attribute)(method.GetCustomAttributes(true)[0])).TypeId.ToString() == "System.ServiceModel.OperationContractAttribute")
                  {                 
                      string methodName = method.Name;
                  }
              }
  </code></pre>
  
  <p>it ends up in an error showing "Index out of bound".</p>