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 the number or character entered through keyboard gets converted to equivalent ascii code & it get stored on ram in the binary form.
which is the institute in hyderabad for providing the live project industry training
Can I create my own metadata attributes?
any one can explain about projectarchitecture and project approach briefly
What are relation objects in dataset?
Explain the number or character entered through keyboard gets converted to equivalent ascii code & it get stored on ram in the binary form. What is the exact procedure. : Dot net architecture
Why the config file might not be writable
Does application frame need host?
i wish to write mcts(microsoft certified technology specialist) exam. can anyone give the model question or format and preparation method?
What is password attribute of the textbox control of .net mobile? : Microsoft dot net mobile
Explain the Lapsed Listener problem in .net
Explain the types of memory management? : .NET Architecture
Can you Explain
Explain about httpruntime.cach.get(); method?
What's new in the .net 2.0 class library?