Treat an awaited operation as a value that becomes available later.

async After an awaited operation completes, the rest of the method can use the returned value like any other local variable.

Awaited Result

storedScore
AwaitedResult.cs
Replay: real traced execution (multi-file project)
using System;

class Program
{
    static int FetchScore(int storedScore)
    {
        return storedScore;
    }

    static void Main()
    {
        int storedScore = 80;
        int score = FetchScore(storedScore);
        string result = score >= 60 ? "pass" : "retry";

        Console.WriteLine($"score={score}");
        Console.WriteLine($"result={result}");
    }
}
using System;

class Program
{
    static int FetchScore(int storedScore)
    {
        return storedScore;
    }

    static void Main()
    {
        int storedScore = 40;
        int score = FetchScore(storedScore);
        string result = score >= 60 ? "pass" : "retry";

        Console.WriteLine($"score={score}");
        Console.WriteLine($"result={result}");
    }
}
using System;

class Program
{
    static int FetchScore(int storedScore)
    {
        return storedScore;
    }

    static void Main()
    {
        int storedScore = 100;
        int score = FetchScore(storedScore);
        string result = score >= 60 ? "pass" : "retry";

        Console.WriteLine($"score={score}");
        Console.WriteLine($"result={result}");
    }
}
  1. storedScore ← 80

    10static void Main()11{12    int storedScore→ 80 = 80; //@storedScore=40, 10013    int score = FetchScore(storedScore80);14    string result = score >= 60 ? "pass" : "retry";
  2. static int FetchScore(int storedScore)

    4{5    static int FetchScore(int storedScore80)6    {7        return storedScore80;8    }
  3. score ← 80, result ← pass

    12    int storedScore = 80; //@storedScore=40, 10013    int score→ 80 = FetchScore(storedScore80);14    string result→ pass = score80 >= 60 ? "pass" : "retry";1516    Console.WriteLine($"score={score80}");17    Console.WriteLine($"result={resultpass}");18}
    outputscore=80
    result=pass
  1. storedScore ← 40

    10static void Main()11{12    int storedScore→ 40 = 40;13    int score = FetchScore(storedScore40);14    string result = score >= 60 ? "pass" : "retry";
  2. static int FetchScore(int storedScore)

    4{5    static int FetchScore(int storedScore40)6    {7        return storedScore40;8    }
  3. score ← 40, result ← retry

    12    int storedScore = 40;13    int score→ 40 = FetchScore(storedScore40);14    string result→ retry = score40 >= 60 ? "pass" : "retry";1516    Console.WriteLine($"score={score40}");17    Console.WriteLine($"result={resultretry}");18}
    outputscore=40
    result=retry
  1. storedScore ← 100

    10static void Main()11{12    int storedScore→ 100 = 100;13    int score = FetchScore(storedScore100);14    string result = score >= 60 ? "pass" : "retry";
  2. static int FetchScore(int storedScore)

    4{5    static int FetchScore(int storedScore100)6    {7        return storedScore100;8    }
  3. score ← 100, result ← pass

    12    int storedScore = 100;13    int score→ 100 = FetchScore(storedScore100);14    string result→ pass = score100 >= 60 ? "pass" : "retry";1516    Console.WriteLine($"score={score100}");17    Console.WriteLine($"result={resultpass}");18}
    outputscore=100
    result=pass