2. I've a class Parent Class A and a Derived Class B. Here
is a scenario.
I've an instance of Class A as objA and an instance of Class
B as objB.
I can refer a child class variable as objB=objA, but
cannot do objA=objB what is the reason?
Answer Posted / ashok
Is this you are trying to do?
class A
{
public int MyName { get; set; }
}
class B : A
{
public int MyName1 { get; set; }
}
public class TestAB
{
public static void Test()
{
A objA = new A();
B objB = new B();
objB = (B)objA; // Unable to cast object of type
'AdvanceLib.A' to type 'AdvanceLib.B'.
objA = objB;
}
}
---
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can you explain atlasuiglitz library?
Explain about .net garbage collector?
what is diffrent beatween localprinter and networkprinter
How can we integrate atlas with web services?
How is the using() pattern useful? What is idisposable?
Explain difference between machine config vs. Web config : Dot net architecture
.Net Frame work arch?
Does application frame need host?
What other than biginteger has been introduced in system.numerics namespace?
Is .net easier than java?
What is one way operation?
What is the problem with .net generics?
inprocess vs out process session state : Dot net architecture
What is the access level of the visibility type internal?
What is the purpose of cache? : Dot net architecture