Translating from javascript into C# (web camera stream code)

Hello guys. I want to have a web camera stream in my project. I found the code and it is working perfectly. I would like to reproduce that code in C# but i lack the skills. Can anyone help out ???

// Continuously get the latest webcam shot from outside "Friday's" in Times Square
  // and DXT compress them at runtime
  var url = "";

  function Start () 
  {
   // Create a texture in DXT1 format
      renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
      while(true) 
      {
      // Start a download of the given URL
         var www = new WWW(url);

      // wait until the download is done
         yield www;

         // assign the downloaded image to the main texture of the object
         www.LoadImageIntoTexture(renderer.material.mainTexture);
       }
    }

Thanks.

Something like this should do it. (name your script "WebCam" to match the class).

using UnityEngine;
using System.Collections;

public class WebCam : MonoBehaviour
{

    public string url = "";

    void Start()
    {
        renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
        StartCoroutine(UpdateCam());
    }

    IEnumerator UpdateCam()
    {
        while (true)
        {
            Debug.Log("reloading webcam");
            WWW www = new WWW(url);
            yield return www;
            www.LoadImageIntoTexture((Texture2D)renderer.material.mainTexture);
        }
    }
}

(Edit - now tested, and bugs fixed!)