[solved]yield for C#

I tryed to use the yield in c# , but the compiler says there are yet a variable called www (see the code).
What can I do?

WWW www= new WWW(URLTex); 
yield www;

I’ve tryed yield(www)and yield () (the name yield does not exists)…but now I have no more ideas…
Heeeelp!(Thanks)

Try yield return www;
Per the C# scripting docs.

Approxlimatly it runs.For the other user I post my solution:

public IEnumerator Wait(int Sec){
		yield return new WaitForSeconds (Sec);
	}
	
	public Texture2D MyLoad(string URL){
		WWW www= new WWW(URL); 
		do{
			Wait(1);
		}while(![url]www.isDone[/url]);
		return [url]www.texture;[/url]
	}

Thanks, maddragon. Your solution helped a lot.

This code doesn’t work as you’d expect. If you call a Coroutine (an IEnumerator function) without StartCoroutine(), it doesn’t run at all. Your code is 100% equivalent to:

    public Texture2D MyLoad(string URL){
        WWW www= new WWW(URL); 
        while(![url]www.isDone[/url]);
        return [url]www.texture;[/url]
    }

This will freeze your entire game for the duration of the web-request (In fact, I’m surprised that it doesn’t freeze your application indefinately, but that’s probably because www calls are handled in a separate thread these days). This may be okay during startup of your game, but it will be a huge performance spike when used during a game.