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 to use lock statement in c#?

494


What is hashmap in c#?

480


What is meaning of type safety in c#?

468


Are structs faster than classes?

539


What is c# used for in the industry?

492






What is oledbconnection c#?

492


What is a decimal in c#?

502


What are delegate methods?

470


What is Assembly. and Describe type of assembly. why most developer happy with private assembly.

580


What is ilist c#?

504


What are actions in c#?

484


What is sqlcommandbuilder c#?

453


Can a struct be null?

494


When should we use delegates in c#?

491


What are the namespace level elements?

504