title: C# RemoveBG API
body: <p>Please anybody can help me to remove the background of an image, using remove bg API. there given once example. but i can't understand it.
  I need to upload image on picturebox and need to get the png in to a picturebox. anybody can give me a compleate example code for this?</p>
  
  <p>remove bg .Net Example is here.</p>
  
  <p><a href="https://www.remove.bg/api" rel="nofollow noreferrer">https://www.remove.bg/api</a></p>
  
  <p>My code is here.</p>
  
  <pre><code>//////////////////////////////////////////////////////////////////////////////
  void removebg()
  {
  using (var client = new HttpClient())
  using (var formData = new MultipartFormDataContent())
  {
  formData.Headers.Add("X-Api-Key",
  "xxxxxxxxkeyxxxxxxxx");
  formData.Add(new
  StringContent("https://www.remove.bg/example.jpg"), "image_url");
  formData.Add(new StringContent("auto"), "size");
  var response =
  client.PostAsync("https://api.remove.bg/v1.0/removebg",
  formData).Result;
  
  if (response.IsSuccessStatusCode)
  {
  FileStream fileStream = new FileStream("no-bg.png",
  FileMode.Create, FileAccess.Write, FileShare.None);
  
  response.Content.CopyToAsync(fileStream).ContinueWith((copyTask) =&gt; {
  fileStream.Close(); });
  
  
  pictureBox1.Load("https://api.remove.bg/v1.0/removebg/no-bg.png");
  }
  else
  {
  MessageBox.Show("Error");
  Console.WriteLine("Error: " +
  response.Content.ReadAsStringAsync().Result);
  }
  }
  }
  /////////////////////////////////////////////////////////////
  </code></pre>