Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

getinstance in c#

Posted on 2006-07-12
5
Medium Priority
?
4,407 Views
Last Modified: 2008-01-09
Hi,

I have convert the below java code into C# like the code given below i want to know whether it is ok or i have to do some other think?.


//Java code
Class c = Class.forName(module);
Object configObj = c.newInstance();


//C# code
System.Type c = System.Type.GetType(module);
System.Object configObj = System.Activator.CreateInstance(c);
0
Comment
Question by:Rahamathulla_J
  • 2
5 Comments
 
LVL 13

Expert Comment

by:devsolns
ID: 17090127
yeah, that is it.
0
 
LVL 3

Accepted Solution

by:
BBK_ earned 750 total points
ID: 17090430
System.Type.GetType will work only with the class which is available in System namespace

If it is in any your own assemble then you can load like
Assembly a = Assembly.LoadFrom(“c:\\test.dll”);
Type c = a.GetType (“test1”);

if you know the class then use
Type c =  typeof(Module);


0
 
LVL 13

Expert Comment

by:devsolns
ID: 17091695
yeah there are a lot of things like that you can point out but I dont see it being handled in java impl.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Screencast - Getting to Know the Pipeline

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question