I have the below Extension (not mine, borrowed for my implementation, but altered a bit) and I am wondering why is the TryGetValue below failing, despite the fact the the pair (string, object - well, var in my case) seem correct.
public static class somExt
{
private static string TimeoutPropertyKey = "RequestTimeout";
public static void SetTimeout( this HttpRequestMessage request, TimeSpan? timeout)
{
if (request == null)
throw new ArgumentNullException(nameof(request));
request.Properties[TimeoutPropertyKey] = timeout;
}
public static TimeSpan? GetTimeout(this HttpRequestMessage request)
{
if (request == null)
throw new ArgumentNullException(nameof(request));
if (request.Properties.TryGetValue(
TimeoutPropertyKey, out var value) // error CS1003: Syntax error, ',' expected - why??
&& value is TimeSpan timeout)
return timeout;
return null;
}
}
Anyone could help me understand and correct the error? Thank you