Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I cast a string into an Object
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00832051
Message ID:
00834132
Views:
24
I think the point is to dynamically access the label at runtime not the string "label1" etc. In addition to using Reflection you can also use the Control collections to find controls by name...

+++ Rick ---

>>I want to cast
>>
>>"label" + Convert.ToString(i)
>>
>>into a System.Windows.Forms.Label so that I can use
>>
>>MessageBox.Show(x.Text);
>>
>>How can I do that?
>
>Why do you want to cast it into a label for the message box?
>
>Can't you just use:
>MessageBox.Show(new String("label" + Convert.ToString(i)));
>
>Or do you have other reasons.
>
>Either way, if you want it to be a label, just create a Label object and set the text property to the string value.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform