Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2004, 12:31 AM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Casting

I want to cast dynamically.
like ...
object lo=(MyObj.GetType())result;

rsult is a parameter getting into function. I don't know it's type at runtime. But I have another object MyObj which is of the same type of result. I want to convert result to the same type as MyObj.

Waiting for your comments.
 
Old November 30th, 2004, 05:59 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can't you just use...
Code:
object lo = result;
Do you have a larger code example so that I can understand your problem?

Kep.
 
Old December 1st, 2004, 12:12 AM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, it worked.

Thanks so much.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Casting? gman997 C# 3 February 11th, 2008 06:11 PM
Casting pfrigo BOOK: Professional .NET 2.0 Generics 3 November 19th, 2007 04:49 PM
Casting - Can you help koco C# 1 September 24th, 2007 08:41 AM
IEnumerator & Dynamic (run-time) Casting. braindead C# 1 May 11th, 2006 05:17 PM
casting ravibodani Access 1 April 4th, 2006 01:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.