1

Is there a way to loop through Settings using an identifier like the following

for (int i = 1; i < 6; i++)
{
    Properties.Settings.Default.["S" + i.ToString()]= 0;//identifier expected
}

To substitute these:

Properties.Settings.Default.S1 = 0;
Properties.Settings.Default.S2 = 0;
Properties.Settings.Default.S3 = 0;
Properties.Settings.Default.S4 = 0;
Properties.Settings.Default.S5 = 0;

Problem is that it's throwing an identifier expected error

DAXaholic
  • 33,312
  • 6
  • 76
  • 74
Newbie404
  • 523
  • 4
  • 7

1 Answers1

1

Try it like so, i.e. remove the dot '.' after Default to invoke the indexing operator

Properties.Settings.Default["S" + i.ToString()]= 0
DAXaholic
  • 33,312
  • 6
  • 76
  • 74