Tag: http response codes

为什么为未使用的变量赋值会对此异步代码的function产生影响?

我有这个代码: private async Task SavePlatypusComplianceFileOnServer(string year, string month) { string monthAsMM = ReportRunnerConstsAndUtils.GetMonthAsMM(month); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(ReportRunnerConstsAndUtils.SERVER_BASE_ADDRESS); String uriToCall = String.Format(“/api/PlatypusCompliance/{0}/{1}{2}”, _unit, year, monthAsMM); HttpResponseMessage response = await client.PostAsync(uriToCall, null); } ……工作正常 不过,看着它,我心里想,“自我,为什么你在不使用它时为”响应“赋值?为什么不在没有它的情况下调用方法?毕竟,Visual Studio或Resharper灰色用“回应”表示你没有实际意义/冗余。“ 所以我将代码更改为: private async Task SavePlatypusComplianceFileOnServer(string year, string month) { . . . // all but the […]