Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C# Invalid expression term '+='

for(int i=0; i <= dataGridView1.Rows.Count; i++)
        {
            string point_value += dataGridView1.Rows[i].Cells[1].Value + "|"; 
        }

Does anyone know why I am getting error (Invalid expression term ‘+=’ for the above code?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

you create new variable with in your for loop that the reason

if you need to store data each loop you should create variable outside loop

like this

string point_value;
for(int i=0; i <= dataGridView1.Rows.Count; i++)
    {
        point_value += dataGridView1.Rows[i].Cells[1].Value + "|"; 
    }

for more information about loop pattern here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading