How do I convert this Javascript function containing yield to C#?

I'm trying to convert a High Score tutorial from Javascript to C#. I've managed to convert all of the functions successfully, save for this one. So far I've gone from this:

function EnterHighScore (score : float) 
{
    // Setup the highscore table text
    SetupHighscoreTableText ();
    // Insert the entry, it might get rejected if the score is not high enough
    var entryIndex = InsertEntry (score);
    if (entryIndex == -1)
    return;
    // Check for the last name the user entered and reuse it
    var inputName = PlayerPrefs.GetString ("LastHighscoreName");
    while (true) 
    {
        for (var c : char in Input.inputString) 
        {
            // Backspace - Remove the last character
            if (c == "\b"[0]) 
            {
                if (inputName.Length != 0)
                inputName = inputName.Substring(0, inputName.Length - 1);
            }
            // End of entry.
            else if (c == "
"[0]) 
            {
            // But the user must have at least entered something
                if (inputName.Length)
                {
                    ChangeName (entryIndex, inputName);
                    SaveEntries ();
                    // Store the name the user entered as the last high score name,
                    // so next time the user doesnt have to enter it again
                    PlayerPrefs.SetString ("LastHighscoreName", inputName);
                    return;
                }
            }   
        // Normal text - just append
            else 
            {
            inputName += c;
            }
        }
        // Make sure the name doesnt grow above max entry length
        if (inputName.Length > maxNameLength)
        inputName = inputName.Substring (0, maxNameLength);

        // Add a "." as a blinking text marker.
        // Show the "." every .5 seconds
        blinkingName = inputName;
        var time = Mathf.Repeat (Time.time, 1.0);
        if (time > .5)
        blinkingName = inputName + ".";
        else
        blinkingName = inputName;
        // Change the name
        ChangeName (entryIndex, blinkingName);
        yield;
    }
}

to this:

void EnterHighScore (float score) 
    {
        // Setup the highscore table text
        SetupHighscoreTableText();
        // Insert the entry, it might get rejected if the score is not high enough
        var entryIndex = InsertEntry (score);

        if (entryIndex == -1)
        return;

        // Check for the last name the user entered and reuse it
        string inputName = PlayerPrefs.GetString("LastHighscoreName");
        while (true) 
            {
                foreach (char c in Input.inputString) 
                {
                    // Backspace - Remove the last character
                    if (c == "\b"[0]) 
                    {
                        if (inputName.Length != 0)
                        inputName = inputName.Substring(0, inputName.Length - 1);
                    }
                    // End of entry.
                    else if (c == "
"[0]) 
                    {
                        // But the user must have at least entered something
                        if (inputName.Length)
                        {
                            ChangeName (entryIndex, inputName);
                            SaveEntries ();
                            // Store the name the user entered as the last high score name,
                            // so next time the user doesnt have to enter it again
                            PlayerPrefs.SetString ("LastHighscoreName", inputName);
                            return;
                        }
                    }
                    // Normal text - just append
                    else 
                    {
                        inputName += c;
                    }
                }

                // Make sure the name doesnt grow above max entry length
                if (inputName.Length > maxNameLength)
                inputName = inputName.Substring (0, maxNameLength);

                // Add a "." as a blinking text marker.
                // Show the "." every .5 seconds
                blinkingName = inputName;
                int time = Mathf.Repeat (Time.time, 1.0);

                if (time > .5)
                blinkingName = inputName + ".";
                else
                blinkingName = inputName;

                // Change the name
                ChangeName(entryIndex, blinkingName);
                yield;
            }
    }

At the line where it says "yield;", I get this error: "Only assignment, call, increment, decrement, and new object expressions can be used as a statement." What am I supposed to change it to?

And how do I convert this line to C#:

var entryIndex = InsertEntry (score);

Also, if you notice any more C# errors in the latter code, I'd appreciate any corrections!! Very much so!!!! ;)

Any function containing yield in Unity is a coroutine, which takes a little more conversion in C#.

First the function declaration needs to be modified so that its return type is IEnumerator, so:

function EnterHighScore (score : float) {

becomes:

public IEnumerator EnterHighScore (float score) {

Next, most yield statements generally needs a "return new" keyword added, eg:

yield WaitForSeconds(5);

becomes:

yield return new WaitForSeconds(5);

And a simple "yield" on its own becomes:

yield return null;

And finally, to call a coroutine in C#, you need to use the special function StartCoroutine(), rather than just call it as a regular function, so:

EnterHighScore(score);

becomes:

StartCoroutine(EnterHighScore(score));

For more information, see: