Jeffrey,
I originally was--I figured out how to get the string representation of the
Enum, so I didn't include in the post but didn't change the title; what i
stumbled on was having a string that labled what type to cast the object
to, and the syntax for making the cast.

thanks for looking at it, though.


Steve Holak
Senior Software Architect

Brokerage Concepts IS Dept.
610-491-4879

email:  [EMAIL PROTECTED]



                    "Block, Jeffrey
                    A."                       To:     [EMAIL PROTECTED]
                    <[EMAIL PROTECTED]        cc:
                    >                         Subject:     Re: [DOTNET] Casting to a 
Type from an Enum
                    Sent by: The
                    DOTNET list will
                    be retired 7/1/02
                    <[EMAIL PROTECTED]
                    VELOP.COM>


                    06/05/2002 06:41
                    PM
                    Please respond to
                    The DOTNET list
                    will be retired
                    7/1/02






Boy...I just re-read your post...I don't think that you were in any way
asking for an enum based object.  Sorry... :(

Jeff Block


-----Original Message-----
From: Steve Holak [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 05, 2002 6:19 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Casting to a Type from an Enum

I'm banging my head on something simple and don't have my references here:

I have an object type returned by a function that has just de-serialized
that object from a database (Soap deserializer) .  The object implements a
known interface (IBar).

I know the type of the original object , but my knowledge of the type is
represented as a string. I want to cast the object to the Type defined by
the string, something like:


void CastTheDamnThing(string whatsthetype)
{
     IBar MyVar;

     object  foo=SomeFunctionThatReturnsAnObjectType();

          //cast the object to the type defined by the string.
     MyVar=(Type.GetType(whatsthetype)) foo;

//do something else . . .

}

It obviously isn't right;
What am I missing?  I feel dumb for asking, but it's the end of the day and
I'm not leaving until I figure out how to do this.

TIA

Steve Holak
Senior Software Architect

Brokerage Concepts IS Dept.
610-491-4879

email:  [EMAIL PROTECTED]

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to