473,670 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create Class from Class Name ie "Class1"

Hi

This is from within an EXE that actaully contains the class - No external
assembly

I would do

Class1 myClass = new Class1();

Now I want

string sClass = "Class1";

How do I create an Instance of Class1 from sClass ???

Thanks
Aug 8 '08 #1
1 2080
sippyuconn wrote:
Hi

This is from within an EXE that actaully contains the class - No
external assembly

I would do

Class1 myClass = new Class1();

Now I want

string sClass = "Class1";

How do I create an Instance of Class1 from sClass ???

Thanks
Use Activator.Creat eInstance(Type. GetType(sClass) );
If the class is in an external dll you need to use the fully qualified
name.

You can obtain the fully qualified name of a class using:
typeof(Class1). FullName;

--
Hans.
Aug 8 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1776
by: Polanski24 | last post by:
Hello! Above function prototype is result of call to UnDecorateSymbolName Win32 API function. My problem is that I am not sure how to understand syntax of second parameter: "float const (* const)". Any hints will be greatly appreciated. Cheers,
2
1728
by: Peter Hemmingsen | last post by:
Hi, I have a dotnet object (implemented in mc++ and used in c#) which have a property called "Info". The Info property is also a dotnet object (implemented in mc++). In the constructor of the "main" object I want to initialize the property "Info" to null in a way that will make the c# programmer (the user) able to write: if (MyObj.Info==null) {..}
2
4724
by: Dave | last post by:
This morning I copied a C# console project file I was working on over the week-end to my workstation and tried to run it. I got the message: Program 'C:\Visual Studio\myProj.exe' does not have an entry point defined My code looks like this: using System; using System.Reflection;
11
2208
by: Antony | last post by:
I know this sounds stupid but I am going to carry on anyway. I want to create an interface that implements all methods of a form, plus another one or two. But I need to know if there is an interface that defines all a forms methods etc. In the example below "System.Windows.Forms.Form" isn't an interface, but it gets my point across. Is there an interface for a form that I can substitute here? Thank you again Tony
4
3831
by: Mike Cooper | last post by:
There is something about inherited classes I evidently don't know... I wrote the following class: Class Class1 inherits System.Windows.Forms.DataGridTextBoxColumn End Class There is absolutely no added functionality to it.
0
2171
by: Benjamin Lukner | last post by:
Hi! I'd like to dynamically call API functions from different DLLs, depending on what platform the program runs. Now I'm wondering what the most simple way may be (without meta code and compiler switches!). I'd like to call it like that: Public Sub xyz()
4
1656
by: Johndow | last post by:
I have trouble to use "Is" operator to a type that is from reflection. Basically, here is what I want to do, if Class1 type is not from reflection: class Class1 { } public class Test { ... if (o is Class1) //to determine if object o is Class1, or is derivative class of Class1
3
1743
by: Arthur Dent | last post by:
Hi all, Im just curious, what is the purpose of the keyword "Overloads" in VB nowadays? I understand conceptually what overloads are and what they do, but im a little puzzled, because if you declare two subs or properties or functions with the same name but different signatures, it seems to overload them without any problem anyway, so why
11
5961
by: Jan | last post by:
I'm using the CSharpCodeProvider to buils some assemblies @ runtime which are never saved as files (cp.GenerateInMemory = true;). The generated assemblies are hierachically dependent on each other so I generate the "bottom" assemblies first. How do I add a dependency to another previously loaded (generated) assembly? I would be happy if CompilerParameters.ReferencedAssemblies.Add could take a System.Reflection.Assembly reference as...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8814
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5684
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2800
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.