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
What is a clickonce application?
What is .net mobile automatic paging? : Microsoft dot net mobile
What are the five stages in a dlx pipeline? : Dot net architecture
Differnce between managed code and unmanaged code ?
Explain pipelining? : Dot net architecture
What are library functions?
Explain .net mobile automatic paging? : Microsoft dot net mobile
What is .net mobile lists. Explain with an example? : Microsoft dot net mobile
What is Video Streaming in .net??
State and explain about microsoft.net?
Explain the Lapsed Listener problem in .net
What is .net mobile utility controls. : Microsoft dot net mobile
4. Wcf- what Asych and Sych call and how that works
what are the events for a form?
Explain the race around condition? : .NET Architecture