Answer the question
In order to leave comments, you need to log in
How to set the values of 15 variables in c#, the names of which change by one?
Good time of the day.
There are 15 variables:
per1
per2
per3
...
per15
How can I set them to different values using a loop? Actually, the question is how to set the iteration value in the name of the variable "per" + i?
if not variables, then values from XAML, x:Name. On PHP or Javascript coped with this task.
I will be very grateful for your help.
Visual Studio IDE, C#
Answer the question
In order to leave comments, you need to log in
Then XAML elements, not variables. Something is wrong anyway, have you tried the ListView?
On the subject: use the FindName() method. It will be something like this:
for (int i = 1; i <= 15; i++)
{
var element = (UIElement) FindName("per" + i);
// ...
}
Generally for such cases indexed variables - arrays are thought up.
But if you want to be perverted - write it down with your hands, 15 variables - not God knows what kind of work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question