title: Use the Extension method instead Built-in method in C#
body: <p>Some Built-in methods are not working for me, I' m using old version of .NetFramework for my application which is not having some new methods. So, I' m trying to create extension methods that overrides the built-in methods. But I' m facing some issues with. Here is the code:</p>
  
  <pre><code>using System; 
  using System.IO; 
  using System.Net;
  using System.Xml;
  using System.Text;  
  using System.Collections.Generic;
  namespace API{
  public static class Retrive 
  {               
      // some variables
  
      public static void CopyTo(this Stream input, Stream output)///Extension method
      {
  
          byte[] buffer = new byte[32768];  
          int read;
  
          while ((read = input.Read(buffer, 0, buffer.Length)) &gt; 0)
          {
              output.Write (buffer, 0, read);
          }
      }   
  
      public static void Main ()
      {
            string url = "https://";          
            string baseURL = "";   
            string authenticateStr = "";
  
          try 
          {
              ///
              }
  
  
          catch (WebException e) 
          {
              using (WebResponse response = e.Response) 
              {
                  ////
              }
          }
      }  // end main()
  }  // end class
  </code></pre>
  
  <p>}//end name space</p>
  
  <p>The errors I' m getting are </p>
  
  <blockquote>
    <p>1) Extension methods must be defined in a top level static class;
    'Retrive' is a nested class .</p>
  </blockquote>
  
  <p>I don' t understand why 'Retrieve' class became nested.</p>
  
  <blockquote>
    <p>2) Extension methods must be defined in a non-Generic static class</p>
  </blockquote>
  
  <p>How to solve these issues? Please help me.</p>
  
  <p>Thank you.</p>