How to update abstract class property value at run time by derived class in c#
I have following abstract class
public abstract class BaseResponse
{
public string TestId{ get; set; }
}
I have two concrete class(TestRequest and TestResponse) derived from above abstract class
public class TestResponse: BaseResponse
{
}
public class TestRequest: BaseResponse
{
}
I have passed some value for TestId in the request parameters. As TestId is used for TestRequest and TestResponse both. when i tried to update the TestId got exception "
object reference not set to an instance of an object
" .Following are the code
private async Task<IEnumerable<testresponse>> GetTestResponse(){
TestResponse testObject = new TestResponse();
testObject.TestId = "some data here";
}
I want to update TestId using TestResponse class, how to achieve it?
Thanks in advance!
What I have tried:
<pre>TestResponse testObject = new TestResponse();
testObject.TestId = "some data here";