我的班级
ClassName
public static explicit operator ClassName(Guid value)
{
return new ClassName(value);
}
这样就可以这样“施放”:
var guids = new[] { Guid.NewGuid, Guid.NewGuid() };
var classes = guids.Select(g => (ClassName)g).ToArray();
如果我有办法
public static ClassName Convert(Guid value)
{
return new ClassName(value);
}
我可以使用方法组:
var guids = new[] { Guid.NewGuid, Guid.NewGuid() };
var classes = guids.Select(ClassName.Convert).ToArray();
有没有一种方法也只传递显式操作符的方法组?
guids.Select(ClassName) // no (obviously)
guids.Select(ClassName.ClassName) // no (obviously)
guids.Select((ClassName)) // no (obviously)
guids.Select(ClassName.op_explicit) // no (obviously)