只是想对语法 sygar进行简单的扩展:
public static bool IsNotEmpty(this ICollection obj)
{
return ((obj != null)
&& (obj.Count > 0));
}
public static bool IsNotEmpty<T>(this ICollection<T> obj)
{
return ((obj != null)
&& (obj.Count > 0));
}
Run Code Online (Sandbox Code Playgroud)
当我使用某些集合时,它工作得很好,但是当我与其他集合一起工作时,我得到了
以下方法或属性之间的调用不明确:“PowerOn.ExtensionsBasic.IsNotEmpty(System.Collections.IList)”和“PowerOn.ExtensionsBasic.IsNotEmpty(System.Collections.Generic.ICollection)”
这个问题有规范的解决方案吗?
不,我不想在调用此方法之前执行强制转换;)