Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

getinstance in c#

Posted on 2006-07-12
5
Medium Priority
?
4,393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 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