Solved

getinstance in c#

Posted on 2006-07-12
5
4,367 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 250 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How come this regular expression allows "e"? 14 56
VB.NET 2008 - SQL Timeout 9 50
How can I do Unit Testing with Session ? 1 23
Selenium and Xpath 4 29
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

763 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