473,387 Members | 1,517 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,387 software developers and data experts.

Create object with dynamically generated name ?



Hello

I need to create some objects durring program execution - but it's names
are dynamically generated (depends on parameters). How can i do it ?

Thanx
Michal
Nov 17 '05 #1
4 2286

vertigo wrote:
Hello

I need to create some objects durring program execution - but it's names
are dynamically generated (depends on parameters). How can i do it ?


What kind of objects? Not all objects have names, after all. If you're
talking about, say, Windows Forms controls, then yes they have a .Name
property, but there don't appear to be any undue complications there.
If however you are trying to say that you want to dynamically generate
object *variables'* names, then we would find ourselves in a state of
confusion.

--
Larry Lard
Replies to group please

Nov 17 '05 #2
Michal,

You will want to take a look at the static CreateInstance method on the
Activator class. It will allow you to create instances from a Type, which
you can get from the static GetType method on the Type class (assuming you
have a string indicating which type you want).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"vertigo" <nu**@com.pl> wrote in message news:op.sw3i77t7zn8jyu@highland...


Hello

I need to create some objects durring program execution - but it's names
are dynamically generated (depends on parameters). How can i do it ?

Thanx
Michal

Nov 17 '05 #3


You can use several ways, depending of what you have:

Activator.CreateInstance
AppDomain.CreateInstance

Check MSDN to see which one is more suitable to your needs

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"vertigo" <nu**@com.pl> wrote in message news:op.sw3i77t7zn8jyu@highland...


Hello

I need to create some objects durring program execution - but it's names
are dynamically generated (depends on parameters). How can i do it ?

Thanx
Michal

Nov 17 '05 #4
You may want to load a class using the name of the class:
http://www.geocities.com/jeff_louie/OOP/oop20.htm

Or you may want to use a dynamic type based class factory:
http://www.geocities.com/jeff_louie/OOP/oop18.htm

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #5

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

Similar topics

16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
3
by: Roman Gordin | last post by:
Hi, I use SVG for web-GUI, but found some serious restrictions 8-( When I use HTML (dynamically generated from .php), I may use HTTPRequest object to provide dynamically regeneration some part...
3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
2
by: macca | last post by:
Hi, I am writing a GUI application. It will have a number of user defined controls( I plan to use/create a user defined control that will output alarm states that the user can also select and...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
1
verbatim
by: verbatim | last post by:
with the following page, the dynamically generated fields are not recognized when i try to submit the form, or add more elements. when i hit my submit button, the address bar has only x1 - x5 in...
7
by: Matt | last post by:
Hi all, I'm trying to create a system where it reads a number of records from a database and then creates a row in the GUI that contains a single field from the database and a button that has a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.