zeinab mokdad
Member
- Joined
- Dec 23, 2021
- Messages
- 13
- Programming Experience
- 5-10
Dears, when wrtitng this generic class
when trying to call this class
can someone explain why is that , and what can we do to prevent this ?
C#:
public static R GetValueFirstItem<T, Q, R>(this Dictionary<T, Q> dict, T key)
where Q : IEnumerable<R>
{
if (!dict.TryGetValue(key, out var r))
return default(R);
if (r == null || r.Count() == 0)
return default(R);
return r.ElementAt(0);
}
Dictionary<string, List<OrderItemInProcess>> orderItemsByType;
var activateConnectivity = orderItemsByType.GetValueFirstItem(ActivateConnectivity);
var addPathResource = orderItemsByType.GetValueFirstItem<string, List<OrderItemInProcess>, OrderItemInProcess>(AddPathResource);
var activateConnectivity = orderItemsByType.GetValueFirstItem(ActivateConnectivity);
will raise and error while var addPathResource = orderItemsByType.GetValueFirstItem<string, List<OrderItemInProcess>, OrderItemInProcess>(AddPathResource);
can someone explain why is that , and what can we do to prevent this ?
Last edited by a moderator: