.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 10th, 2003, 08:00 AM
moreiram moreiram is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 moreiram User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How can I create a Dynamic variable in .NET?

HI, How can I create a Dynamic variable in .NET?

For instance, I need to create a dynamic variable imagine the following code:

Dim var1 as String ="Test"

Imagine that the variable "var1" doesn't exit and I need create it without declared nothing, where everything was Dynamic, For example I Wouldn't this declaration "Dim var1 as String" .

For example, I would need something like it: I need create a specific method like it:


newmethod (newvariable,value)

For example:

newmethod ("var1","Test")

imagine it would be possible too:

newmethod ("var2",var1)

and it too:

newmethod ("var3",var2)

So, Imagine When I Wanted to get the value I used a another method like this:

evaluate(var1)

response.write (evaluate(var1))

Display: Test

evaluate(var2)

response.write (evaluate(var2))

Display: Test


Please I Need your help about it.

Reply With Quote
  #2  
Old July 10th, 2003, 11:28 PM
Andrew Andrew is offline
dotNetBB Forums Developer
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 265 Andrew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Andrew Send a message via AIM to Andrew Send a message via Yahoo to Andrew
If you are only dealing with strings, or items that can be used as strings, you could try using a hashtable.

'-- declare
Dim myHash As Hashtable = New Hashtable(100) '-- initialize with 100, though it will resize automatically

'-- add
myHash.Add("var1", "the value")

'-- see if it exists
If myHash.Contains("var1") Then
...
End If

'-- get the value
Dim myString = myHash("var1")

Remember though, that the key (var1 in this example) has to be unique. Its always a good idea to check to see if the key exists before you try creating a new entry to ensure you aren't going to try using a key thats's already been defined.
__________________
Building a better community one post at a time.
dotNetBB Forums

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > How can I create a Dynamic variable in .NET?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT