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

Explain difference between machine config vs. Web config? : .NET Architecture

1021


Waht is Dot net Arcitecture

2464


What are the main Tools to develop .Net Application?

1010


Explain hard disk and what is its purpose? : Dot net architecture

1009


What is one way operation?

1015


How to improve the cache performance? : Dot net architecture

976


Explain 'managed' mean in the .NET context

1170


What is a clickonce application?

978


What is cookie less session?

1061


Explain the types of memory management? : Dot net architecture

1012


What is gui programming? : .NET Architecture

973


Explain the difference between l1 and l2 cache? : .NET Architecture

1085


Explain How to improve the cache performance? : Dot net architecture

986


what is sessions and cookies take one example simple way to understand

2388


what are constructors and destructors?

2198