Did it possible to cast a generic type of derived class to
generic type of base class?

Answer Posted / lalit pradhan

Good explaination Karthikeyant :)
Also in addition to that the following cast is also not
possible. It will compile but give you casting error on
compile time.

DerivedClassGenrics<int> derivedClassGenrics = new
DerivedClassGenrics<int>();

BaseClassGenrics<int> baseClassGenrics = new
BaseClassGenrics<int>();

derivedClassGenrics = (DerivedClassGenrics<int>)
baseClassGenrics;

Enjoy!!!
Lalit Pradhan a.k.a DOTNET Gadha

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use partial class in c#?

481


Can we maintain state in webservice?

495


What are the benefits of using generics?

467


What is default parameter in c#?

503


What is a deadlock lock?

489






What is a float?

492


Is it possible to have different access modifiers on the get/set methods of a property in c#?

595


What is cts, clr?

429


How many bytes is an int in c#?

502


What is a delegate? Explain.

535


How we can create an array with non-default values?

502


What are the different ways of method can be overloaded?

449


What are jump statements in c#?

499


What is c sharp language?

502


Which class does the remote object has to inherit?

604