My Class Structure is Like This.
Class A
{
}
Class B:A{..}
Class Demo
{
//Here Actual Parameter is instance of Class B. But in xyz function accepts
// parameter of type Class A. So in Below function can i get the Properties of
//Class B by using "((B)a).Property_Name", But i don want to specify the Name
//of Class B. So is ther any approach to meet my need.
public void xyz(A a){ ....Here I Can i get }
}
It sounds like you want to use a member of
Bthat doesn’t exist inAin a method that takes inAas a parameter. You don’t want to move the member toAbecause it probably does’t make sense to do so and you want something special when a B is passed in.The most straight forward way is to test for it
However this is bad because maybe you have C that needs this to.
Then maybe its better to introduce an interface e.g.
B: A, ISomthing
Another option is to use Double Dispatch