I agree with Colin for the most part. It seems as though you are looking to use the class itself as a way to represent some information about the instance. Although as you mentioned this can work in C++, C# works very differently, and the type of an object really represents two things: first of all, the actual type of the instance, and secondly (in the case of base classes) a common interface (since subclassing is really just a way of implementing the base class's interface, from the perspective of someone using the object). Anyhow, if you were to cast the instance of ref Book b to a CheckedOutBook inside CheckOut(), this would actually only apply to the local representation of b, and even though it's marked as ref, would not affect the object passed into it, namely because that object in the calling method already has an interpretation (type), and ref parameters allow an object to be changed, not how it is interpreted (i.e. its local apparent type). As far as it being a "DON'T DO THIS EVER" thing, I think you'll quickly realize that it won't work, so it's not so much a warning as there's just no point in doing it. Now that said, you might actually be able to do something like what you want by creating a new object of type CheckedOutBook, setting it as somehow equivalent to the passed-in Book, and then setting the ref b parameter to equal the new instance (since it is still a Book). The key is that you will have to create a new object, and the old one will still be floating around so long as it is used (elsewhere). However you appear to be aware of this scenario. The short answer is no, you cannot "transform" a reference to be some type other than how it was created. Not in C#.
“Time and space can be a bitch.” –Gushie, Quantum Leap {o,o}.oO( Looking for a great RSS reader? Try FeedBeast! ) |)””’) Built with home-grown CodeProject components! -”-”-