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
Explain difference between machine config vs. Web config? : .NET Architecture
Waht is Dot net Arcitecture
What are the main Tools to develop .Net Application?
Explain hard disk and what is its purpose? : Dot net architecture
What is one way operation?
How to improve the cache performance? : Dot net architecture
Explain 'managed' mean in the .NET context
What is a clickonce application?
What is cookie less session?
Explain the types of memory management? : Dot net architecture
What is gui programming? : .NET Architecture
Explain the difference between l1 and l2 cache? : .NET Architecture
Explain How to improve the cache performance? : Dot net architecture
what is sessions and cookies take one example simple way to understand
what are constructors and destructors?