Solved

getinstance in c#

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now