C# - Concatenate inside a loop

Is it possible to concatenate inside a C# loop? Below is my sample code:

 for (int i = 0; i <= metricCount; i++)
 {
      if (m.metrictNumber == i)
      {
         aggrgt.Add(new PlainBrgDataSummaryChartAggrgt
         {
            scoreWk6 = scoresPerDuration.scoresPerDuration.scoreWk6.metricScore1,
            scoreWk5 = scoresPerDuration.scoresPerDuration.scoreWk5.metricScore1,
            scoreWk4 = scoresPerDuration.scoresPerDuration.scoreWk4.metricScore1,
            scoreWk3 = scoresPerDuration.scoresPerDuration.scoreWk3.metricScore1,
            scoreWk2 = scoresPerDuration.scoresPerDuration.scoreWk2.metricScore1,
            scoreWk1 = scoresPerDuration.scoresPerDuration.scoreWk1.metricScore1

         });

       }
 }

What I want is to concatenate metricScore1.

Here's what I tried:

scoreWk6 = scoresPerDuration.scoresPerDuration.scoreWk6.metricScore + i,

Is that possible?

Answers


You cannot. If you see numbers in variable names, it's probably wrong. Numbering your variables means you should have used a container type. Either an array or a list or anything else that supports going through it with a loop index or foreach.

So the answer is no. No, you cannot. You should change the types holding your data.


Need Your Help

How to create a table with columns named after values in other table

python postgresql psycopg2

I have a table, call it that has the column attr_name. How do I create a new table using the values from each row in attr_name? I think I'm close

Android Twitter exception error :(

java android twitter twitter4j

Started coding up a simple android app. Part of it pulls the users last 20 tweets and saves them to a database. When I run this, statuses = twitter.getUserTimeline(); throws an exception its handle...