Re: using Type

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,

No, you cannot do that.

What is what you want to do?

You could use reflection to call members of T though.


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jinsong Liu" <Jinsong@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:h6ui929s8ra4lk23i7ia8e46kslkumodg5@xxxxxxxxxx
I have a function, which accept two parameters, one is a object,
another is a Type. I need to cast the object to the type define by
Type. is it possible?

void MyFunction(Object O, Type T)
{
// this is what I want to do
T MyObject=(T)O;
}


.



Relevant Pages

  • Re: Using built in dialog boxes - how to determine arguments?
    ... > argument lists of a specific dialog with reflection? ... "Interactions with built-in Word dialog boxes are through late binding, ... You must use the Reflection libraries to ... access dialog box members." ...
    (microsoft.public.vsnet.vstools.office)
  • Re: How to access private members of a base class
    ... private members, and so on, and so on... ... > I already use reflection, ... But I CANNOT obtain the PRIVATE members of the base ... >>> members of its base classes.(I already have the ReflectionPermission) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Strange behavior or where is SecurityException?
    ... be know that ReflectionPermission no longer protects access to non-public ... it does still protect use of non-public members. ... // Accessing private members requires Reflection Permission ...
    (microsoft.public.dotnet.security)
  • Re: comparing object values
    ... Please suggest whether reflection will work in this case? ... participate in comparisons and some members that should not. ... Each unless a subclass needs to ... comparison and then include their own for their added data members, ...
    (microsoft.public.dotnet.framework)
  • Re: comparing object values
    ... But using reflection will not necessarily always produce the correct results either. ... For most classes that have a need to be comparable, they contain some members that should participate in comparisons and some members that should not. ... Each unless a subclass needs to insert one of its own data members in the middle of the order of comparison for the parent class, all they need to do is do the parent's comparison and then include their own for their added data members, if any. ...
    (microsoft.public.dotnet.framework)