jxycms
5/21/2018 - 7:38 AM

C# Tuple

public async Task<Tuple<DateTime?, string>> GetWithdrawalInfo(string studentNumber, string parentDecision)
{
    if (true) // just in case that Id is some other service like Completion ....
    {
        return Tuple.Create<DateTime?, string>(value1, value2);
    }
    return Tuple.Create<DateTime?, string>(null, string.Empty);
}

how to get value:

var item = await GetWithdrawalInfo(param1, param2);

value1 = item.Item1;
value2 = item.Item2;
1. install System.ValueTuple

2. 

public async Task<(string fieldValue, string cookieValue)> ExtractAntiForgeryValues(HttpResponseMessage response)
{
    return (ExtractAntiForgeryToken(await response.Content.ReadAsStringAsync()),
                                    ExtractAntiForgeryCookieValueFrom(response));
}

or

public (string fieldValue, string cookieValue) ExtractAntiForgeryValues(HttpResponseMessage response)
{
    return (ExtractAntiForgeryToken(""),
                                    ExtractAntiForgeryCookieValueFrom(response));
}

3. 

assume class name is TestServerFixture

I can get value by

var antiForgeryValues = await TestServerFixture.ExtractAntiForgeryValues(initialResponse);

string fieldValue = antiForgeryValues.fieldValue
string cookieValue = antiForgeryValues.cookieValue