Ryvik
Ryvik

Reputation: 473

Use the result of a method as a parameter inside another method

I'd like to take the result of a method and use the result of that in a parameter inside another function.

Example:

 public static async Task<string> GetToken(string User, string Pass)
        {
          //do stuff
         return token;
        }
 public static async Task<GraphServiceClient> Auth()
        {
          AuthenticationHeaderValue("bearer", GetToken());
         }

Obviously not a working example, but hopefully it gets the point across. GetToken is taking command line arguments, hence the need for the User+Pass strings.

Upvotes: 0

Views: 49

Answers (1)

Ali Faris
Ali Faris

Reputation: 18630

you should use await keyword

public static async Task<GraphServiceClient> Auth()
{
    var token = await GetToken('username' , 'password');
    AuthenticationHeaderValue("bearer", token);
}

Upvotes: 2

Related Questions