Hello I am working on my Accumulate test score data form and have hit a wall.
Here is my code so far.. I am having trouble with line 42 add/store scoreInt to the scoresList collection. needs to have a range of 1-100.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ScoreCalculator
{
    public partial class ListForm : Form
    {
        private int totalInt = 0;


        List<int> scoresList = new List<int>();

        public ListForm()
        {
            InitializeComponent();
        }

        private void btnExit_Click(object sender, System.EventArgs e)
        {
            this.Close();
        }

        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            int scoreInt = 0;
            int countInt = 0;
            decimal averageDec = 0;

            try
            {
                if (IsValidData())
                {

                    scoreInt = int.Parse(txtScore.Text);

                    //// TODO# - add/store scoreInt to the scoresList collection
                    List<int> scoresList = new List<int>();





                    averageDec = totalInt / countInt;
                    lblScoreTotal.Text = totalInt.ToString();
                    lblScoreCount.Text = countInt.ToString();
                    lblAverage.Text = averageDec.ToString();
                    txtScore.Focus();
                    txtScore.SelectAll();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" +
                ex.GetType().ToString() + "\n" +
                ex.StackTrace, "Exception");
            }
        }

        private void btnDisplay_Click(object sender, System.EventArgs e)
        {


            string scoresString = "";




            scoresString += score.ToString() + "\n";



            // Display in messagebox
            MessageBox.Show(scoresString, "Sorted Scores in the List<>");
            txtScore.Focus();
            txtScore.SelectAll();
        }

        private void btnClear_Click(object sender, System.EventArgs e)
        {



            totalInt = 0;
            txtScore.Text = "";
            lblScoreTotal.Text = "";
            lblScoreCount.Text = "";
            lblAverage.Text = "";
            txtScore.Focus();
            txtScore.SelectAll();
        }

        public bool IsValidData()
        {
            return
                // Validate the Operand1 text box
                Validation.IsPresent(txtScore, "Score") &&
                Validation.IsInt32(txtScore, "Score") &&
                Validation.IsWithinRange(txtScore, "Score", 01, 100);
        }

        private void btnArrayForm_Click(object sender, EventArgs e)
        {
            // Instantiate a new ArrayForm and display it modally
            ArrayForm aForm = new ArrayForm();
            aForm.ShowDialog();
        }

    }
}

List<int> scoresList = new List<int>();
You did that already on line 17, which is good.
Replace line 43 with: scoresList.Add(scoreInt);

Don't feel sorry. Sometimes I make dummier mistakes.
Happy programming! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.