1
我面临接口扩展接口的问题。让我们来举例接口扩展接口属性
public interface IBaseClient
{
int PatientId { get; set; }
string PatientName { get; set; }
}
public interface IEchoClient2 : IBaseClient
{
string StudyInstanceUID{ get; set; }
}
我正在实现这个接口IEchoClient2类。
class RestClient2 : IEchoClient2
{
public string StudyInstanceUID
{
get;
set;
}
new public int PatientId
{
get;
set;
}
new public string PatientName
{
get;
set;
}
static void Main(string[] args)
{
IEchoClient2 client2 = new RestClient2();
client2.PatientId = 1;
client2.PatientName = "XYZ";
client2.StudyInstanceUID = "11";
JsonSerializer objJsonSerializer = new JsonSerializer();
objJsonSerializer.JsonConverter(client2);
}
}
public class JsonSerializer
{
public void JsonConverter(IEchoClient2 client2)
{
JsonRestService.JsonRESTClient client = new JsonRestService.JsonRESTClient();
}
}
但是当我通过接口对象JsonConverter(IEchoClient2 client2)
方法,它仅显示IClient2界面属性。我如何获得所有基础接口支持以及衍生接口支持。
在这张图片中,你会发现只有StudyInstanceUID显示不是其他两个道具。 我怎样才能得到这两个基础接口的道具。
为什么你要做'新的公共等....'? –
“IEchoClient2”的定义在哪里? – ekad
immage只显示'ICilent2'的属性,因为'client2'是该接口的一个实例。如果你想访问其他属性,你也可以简单地转换到该接口。 – HimBromBeere