Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is a clickonce application?

890


What is .net mobile automatic paging? : Microsoft dot net mobile

948


What are the five stages in a dlx pipeline? : Dot net architecture

952


Differnce between managed code and unmanaged code ?

1008


Explain pipelining? : Dot net architecture

960


What are library functions?

913


Explain .net mobile automatic paging? : Microsoft dot net mobile

891


What is .net mobile lists. Explain with an example? : Microsoft dot net mobile

854


What is Video Streaming in .net??

929


State and explain about microsoft.net?

909


Explain the Lapsed Listener problem in .net

1117


What is .net mobile utility controls. : Microsoft dot net mobile

941


4. Wcf- what Asych and Sych call and how that works

1902


what are the events for a form?

2062


Explain the race around condition? : .NET Architecture

958