Making flag depend on counter c#
<p>I want to make a flag that depend on cntkotak on my program. Here I have cntkotak that will count until 3. During cntkotak counting, my flag variable will increase depend on value of cntkotak. For example My cntkotak value is 3 and my flag will be flag3 = true. If my cntkotak value is 2, my flag will be flag2 = true. It's kinda bool flag + cntkotak = true, but it doesn't work. That's my idea but I don't know how to implement it. Please help me</p>

<pre><code>foreach (var filePath in templateImage)
{
    counterbanyaktemplate++;
    for (cntkotak = 0; cntkotak &lt; banyakkotak; cntkotak++)
    {
        Image&lt;Bgr, byte&gt; templates = new Image&lt;Bgr, byte&gt;(filePath);
        imageToShow.ROI = new Rectangle(x1 + ((tempwidth / banyakkotak) * cntkotak), y1, tempwidth / banyakkotak, tempheight);                        
        using (Image&lt;Gray, float&gt; result = imageToShow.MatchTemplate(templates, Emgu.CV.CvEnum.TM_TYPE.CV_TM_CCOEFF_NORMED))
        {
            double[] maxValues, minValues;
            Point[] maxLoc, minLoc;
            result.MinMax(out minValues, out maxValues, out minLoc, out maxLoc);


            if (counterbanyaktemplate == ((cntkotak + 1) + (banyakkotak * pengali)))
                {
                    if (maxValues[0] &gt; 0.8)
                    {
                      //here i want to make a flag that depend on cntkotak.
                   if(flag == true)
                  {

                            Rectangle match = new Rectangle(x1 + ((tempwidth / banyakkotak) * cntkotak), y1, tempwidth / banyakkotak, tempheight);

                            newImage.Draw(match, new Bgr(Color.Green), 1);
                        }
                        else
                        {
                            Rectangle match = new Rectangle(x1 + ((tempwidth / banyakkotak) * cntkotak), y1, tempwidth / banyakkotak, tempheight);
                            newImage.Draw(match, new Bgr(Color.Red), 1);
                        }

                        if (cntkotak == banyakkotak - 1)
                        {
                            cntkotak = -1;
                            pengali++;
                        }
                        if (pengali == banyakkotak - 1)
                        {
                            pengali = 0;
                        }
                    }
                }

            }    
        }
</code></pre>