Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any way to accomplish this ?

 
Alex Qiu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Such as
Hashtable lvHT = new Hashtable();
Object obj = lvHT;
// Then how to automatically cast the obj back to Hashtable ?
If write code , I can cast it (Hashtable)obj , but how can it "automatically" cast back ?
Is there any way to do this ?
 
Sabarish Sasidharan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Downcasting (casting from super-type to a type lower in the hierarchy) will not be possible automatically. I don't think this automatic conversion is possible.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you use such an "automatical cast" at all? Can you give an example where you would like to use it?
 
Alex Qiu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wondering when writing code ...
It seems no way , so post this topic .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic