TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dtmoore
NA
8
0
Using a string to reference an object.
May 13 2005 4:12 PM
I am fairly new to C# and have been banging my head on my desk for a couple hours trying to figure this out, I am almost to the point where I think it cannot be done. Here is the problem. I have a series of textfields named in a sequential manner as follows: ex_1_1 ex_1_2 etc... I need to do a fairly large amount of math with these boxes and as the matrix of them spans quite a ways in both dimensions i really don't want to have to hardcode each reference (which is the reason for the naming) I planned on running a for loop and pulling the data out that way. I am getting an error when I try to do this. here is the code I am using for(int i=1; i<7; i++) { tempValue += ("em_1_" + i).Value } now this obviusly blows up because ("em_1_" + i) is a string not an object reference, but what I need is a way to make it reference my textfield. I have done this same thing in several other languages but cannot get it to work. Any help you could give me would be greatly appreciaited. thanks ~David
Reply
Answers (
5
)
Showing an empty textbox using collections
Refactoring for free?