Re: How do I create an object?

From: Jim Robertson (JimRobertson_at_discussions.microsoft.com)
Date: 03/21/05


Date: Mon, 21 Mar 2005 15:01:04 -0800

Thanks! That's what I was looking for.
I hope the new parametrized type feature of C# will also have reflection
support.
-- Jim Robertson

"William DePalo [MVP VC++]" wrote:

> "Jim Robertson" <JimRobertson@discussions.microsoft.com> wrote in message
> news:430FB08F-EFF6-47C9-832D-C93C9AE80F18@microsoft.com...
> > Is there a way to instantiate an object whose type isn't known until
> > runtime?
> > Something comparable to Java's Class.newInstance()?
>
> Yup. Check the docs for Activator.CreateInstance().
>
> Just btw, like Java, .Net supports reflection so you'll be able to get an
> instance of a class if you like and inspect it for methods and members as
> well, if you have a need to do that.
>
> Regards,
> Will
>
>
>
>



Relevant Pages

  • Re: Reflection, how to understand
    ... I'm trying understand jdk 5 reflection. ... Then it proceeds to get a constructor for said class, ... Then it proceeds to instantiate the object using said constructor, ... I use that code snippet for persistence of simple objects ...
    (comp.lang.java.programmer)
  • Re: Reflection
    ... Alternatively you can use Reflection, ... > constructor, how do i go about instantiating it. ... > but for some odd reason i never am able to instantiate my objects ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Prevent DLL usage
    ... "Pavel Minaev" wrote in message ... and it seems to do the trick too. ... FullTrust assembly from using reflection to instantiate your classes ... I'd neglected to consider instantiation through reflection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I create an object?
    ... System.ServiceModel.ServiceHostfooService = new ... > Yes generics have reflection support: ... > I hope the new parametrized type feature of C# will also have reflection ...
    (microsoft.public.dotnet.framework)
  • ReflectionOnlyLoad in Macro
    ... I am trying to do a reflection only load of an assembly, ... create new app domain ... instantiate class ...
    (microsoft.public.dotnet.languages.vb)