473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

eval a String to have a type

Eva
Hi,

My problem is about I have a class name in a string
variable and I need create objects for that class. ¿How am
I able to use the string variable for it?

I have another problem. The class in the first problem is
a form that I'm try to open. The form is created
externally by the user (so isn't in my project) ¿Is
possible to use it without convert the .cs file in a DLL?

Thanks a lot,
Eva.
Nov 15 '05 #1
1 967
Eva <an*******@discussions.microsoft.com> wrote:
My problem is about I have a class name in a string
variable and I need create objects for that class. ¿How am
I able to use the string variable for it?
See Activator.CreateInstance, or if you need to call a specific
constructor, you can use Type.GetType() and then get the specific
constructor and invoke it.
I have another problem. The class in the first problem is
a form that I'm try to open. The form is created
externally by the user (so isn't in my project) ¿Is
possible to use it without convert the .cs file in a DLL?


Yes - have a class library project instead of an application. In this
case you'll need to load the assembly and then use Assembly.GetType
instead of just Type.GetType.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

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

Similar topics

9
by: Mike | last post by:
After reading much on the evils of eval, I have a question using my own personal use of the function... We have a reports system that will generate reports based on a number of parameters...
3
by: Jeremy Sanders | last post by:
Hi - I'm trying to subclass a dict which is used as the globals environment of an eval expression. For instance: class Foo(dict): def __init__(self): self.update(globals()) self = 42
1
by: J.B. | last post by:
Hi all. I'm rather new to C#, (just learning ;-) and i'm making my own 'helper' library, in wich i want to have an eval(statement) function. Anyone know how to make this / help me out on where...
5
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash...
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
8
by: | last post by:
The problem lies here eval("document.TeeForm.amt.value(S+M)"); S and M suppose to add up and the total suppose to appear on the AMT field but it didn't. Any help? ...
8
by: fredo | last post by:
This question was asked in comp.lang.javascript with no result. In IE5.x and IE6, I want to display an image when the user rolls over a text link. The image does indeed display, but only on the...
0
by: J. Clifford Dyer | last post by:
On Tue, 2007-12-11 at 16:55 -0800, katie smith wrote: Katie, First, please provide a useful subject heading when posting to the list. It makes everyone's life easier when searching the...
10
by: Gordon | last post by:
I have a script that creates new objects based on the value of a form field. Basically, the code looks like this. eval ('new ' + objType.value + '(val1, val2, val3'); objType is a select with...
16
by: Fett | last post by:
I am creating a program that requires some data that must be kept up to date. What I plan is to put this data up on a web-site then have the program periodically pull the data off the web-site. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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...

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.