如何从2个不同的类中执行隐式运算符?
public class A
{
public int one { get; set; }
public int two { get; set; }
public static implicit operator A(B v)
{
\\one = v.one; \\ static Error.
\\this.one = v.one; \\ Error
}
}
public class B
{
public int one { get; set; }
public int two { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
}
static void Main(string[] args)
{
A a = new A();
B b = new B();
a = b;
}
感谢。
答案 0 :(得分:6)
您需要在隐式转换中返回svc.cluster.local cluster.local
的新实例:
A