Hi techs
dim country as string
country="INDIA"
dim country as new System.Collections.ArrayList()
I need to give an object name dynamically...
How can i set an objectname dynamically ... dynamic input will be in string format ....
thankzzz
Printable View
Hi techs
dim country as string
country="INDIA"
dim country as new System.Collections.ArrayList()
I need to give an object name dynamically...
How can i set an objectname dynamically ... dynamic input will be in string format ....
thankzzz
I'm afraid you are confused. How can the user provide a variable name at run time when variable names don't exist at run time? Variable names are just identifiers so the developer can recognise what the variable is for. Once you compile your code those names cease to exist because the system doesn't need them.
Not only that, variables are NOT object names. A variable is NOT an object. Look at this code:There are three variables (obj1, obj2 and obj3) and only one object, so what's the object's name? The answer is that it doesn't have a name. It's just an object referred to by three different variables. Now look at this:vb.net Code:
Dim obj1 As New Object Dim obj2 As Object = obj1 Dim obj3 As Object = obj2Now there are three variables named ctl1, ctl2 and ctl3, plus there's one Control object. This control does have a name because the Control class has a Name property. That property has no relationship whatsoever to the variables that may refer to the object.vb.net Code:
Dim ctl1 As New Control ctl1.Name = "A new control" Dim ctl2 As Control = ctl1 Dim ctl3 As Control = ctl2
Now, hopefully I've demonstrated that what you've asked for makes no sense, so please explain what the intended functionality is and we can try to advise how to achieve it.
Quote:
Originally Posted by jmcilhinney
Ok, My probs is this :
I have a Class file Authentication.cs
I want to create n number of authentication class objects...
objects ....
thankzzz
Quote:
Originally Posted by sureshvijayan
I have a Class file Authentication.cs
I want to create n number of authentication class objects...
Can't you simply create a collection of Authentication objects?
As stanav suggests, if you want multiple objects of a type then create multiple objects of that type and put them in a collection. You could use a List(Of Authentication) or, if you want each one identified by a unique string, a Dictionary(Of String, Authentication).
The collections I mention are only available from .NET 2.0. As you haven't specified your version I will assume that that's what you're using. Please specify in future regardless.