Reputation: 2224
I am facing problem regarding the interface extends interface. Lets go with example
public interface IBaseClient
{
int PatientId { get; set; }
string PatientName { get; set; }
}
public interface IEchoClient2 : IBaseClient
{
string StudyInstanceUID{ get; set; }
}
I am implementing this interface IEchoClient2 into class.
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();
}
}
but when I pass interface object to JsonConverter(IEchoClient2 client2)
method, it displays only IClient2 interface property. How I can get all base interface prop as wel as derived interface prop.
in this image you'll observe that only StudyInstanceUID is shown not other two prop. How can I get these two prop of base interface.
Upvotes: 1
Views: 442
Reputation: 70652
Your concern is simply how the debugger works. The properties are there, but the debugger limits your view to the immediate class's declared properties by default. You need to expand "client2" in the debugger's variable value tooltip window to see the other base properties.
Note that had you written any code in the method that actually used client
, all of the properties would be available directly (e.g. through Intellisense). It's just the debugger trying to not bombard you with too much information that causes the properties to not be immediately visible when debugging.
Upvotes: 1