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?
Answers were Sorted based on User's Feedback
Answer / gopal
Here ObjA is Base Class and ObjB is Derived Class.
In Inheritence Process Derived class Will get the all
features of Base Class.
because objB=O=objA Is COrrect
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
What is different about namespace declaration when comparing that to package declaration in java?
How resource files are used in .net?
Explain about validation?
How do I stop a thread?
What is an asssembly qualified name? Is it a filename? How is it different?
Explain the purpose of cache? How is it used? : .NET Architecture
What is password attribute of the textbox control of .net mobile? : Microsoft dot net mobile
Explain difference between machine config vs. Web config? : .NET Architecture
Explain the components required to develop mobile applications with .net mobile? : Microsoft dot net mobile
Name some changes done since version 3.0?
Can you explain scriptmanager control?
What should one do to make class serializable?