C# Yield in a Method with Return a value

hello :slight_smile:

I’m trying to yield until a www is finished and than return a specific answer like:

public IEnumerator checkBetaKey(string betacode, string betaname){

		form = new WWWForm ();

		form.AddField ("betacode", betacode);
		form.AddField ("betaname", betaname);

		headers = form.headers;
		rawData = form.data;

		//set Auth Key in Type:    "Basic : Name:Key"
		headers ["Authorization"] = "Basic " + System.Convert.ToBase64String (System.Text.ASCIIEncoding.ASCII.GetBytes(betaname + ":" + betacode));

		www = new WWW (url, form, headers);

		yield return www;

		if (www.error != "") {
			return false;
		} else {
			if (www.text == "true") {
				return true;
			} else {
				return false;
			}
		}
	}

but there are some Errors:
Argument #2' cannot convert UnityEngine.WWWForm’ expression to type byte[]' The best overloaded method match for UnityEngine.WWW.WWW(string, byte, System.Collections.Hashtable)’ has some invalid arguments

Cannot implicitly convert type System.Collections.IEnumerator' to bool’ (When I try to use the Method).

Have you any ideas? :slight_smile:

First I think you’ve meant to call www = new WWW(url, form);

Next you can’t return false or return true from coroutine as its return value is IEnumerator. Consider setting variable defined in class with its return value instead.