PC Review


Reply
Thread Tools Rate Thread

Declaring a type with identifier as an expression

 
 
Rabih
Guest
Posts: n/a
 
      13th Aug 2003
Hi
How do you dynamically declare a type using an expression
for the identifier.

eg :

for x =1 to 10
Dim myObj+str(x) as object
next


Many thanks
 
Reply With Quote
 
 
 
 
Jon Skeet
Guest
Posts: n/a
 
      13th Aug 2003
Rabih <(E-Mail Removed)> wrote:
> How do you dynamically declare a type using an expression
> for the identifier.
>
> eg :
>
> for x =1 to 10
> Dim myObj+str(x) as object
> next


Generally, you don't - you use an array or map of some kind (such as
Hashtable) instead. Now, why do you particularly *want* to do it in
this case?

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
 
Reply With Quote
 
Günter Prossliner
Guest
Posts: n/a
 
      13th Aug 2003
You must use an array:

Dim myObj(10) As Object
myObj(1) = "Wert 1"
myObj(2) = "Wert 2"
Console.WriteLine(myObj(2)) 'Writes "Wert2" to the console


"Rabih" <(E-Mail Removed)> wrote in message
news:039101c36170$94d8bf50$(E-Mail Removed)...
> Hi
> How do you dynamically declare a type using an expression
> for the identifier.
>
> eg :
>
> for x =1 to 10
> Dim myObj+str(x) as object
> next
>
>
> Many thanks



 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error: "type parameter declaration must be an identifier nota type" Jazer Microsoft C# .NET 1 13th Jan 2009 02:45 PM
Declaring Data Type of Array tfischer@mad.scientist.com Microsoft Excel Programming 8 7th Feb 2006 05:53 AM
declaring array of type Dim q As Double(,) =?Utf-8?B?bWFyaw==?= Microsoft VB .NET 3 2nd Feb 2005 03:34 AM
Declaring an extended value type =?Utf-8?B?TWljaGFlbC5NY0Q=?= Microsoft C# .NET 6 17th Jan 2005 01:14 PM
Get declaring type Maarten Terlingen Microsoft C# .NET 1 19th Dec 2003 04:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:35 PM.