【发布时间】:2020-03-09 10:28:23
【问题描述】:
我有这个代码 sn-p:
public interface Imy
{
int X { get; set; }
}
public class MyImpl : Imy
{
private int _x;
int Imy.X
{
get => _x;
set => _x = value;
}
}
class Program
{
static void Main(string[] args)
{
var o = new MyImpl();
o.Imy.X = 3;//error
o.X = 3;//error
}
}
我只想为 X 赋值,但得到 2 个编译错误。如何解决?
【问题讨论】:
标签: c# interface properties compilation explicit