© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
31 replies
Array

Help with Arrays in my code?

https://paste.mod.gg/giovsrlllnke/0
Having a bit of an issue with my code. Working on an assignment where I have to load code in from a textfile and it's supposed to load in blocks. My teacher has detailed some header comments on the process, but I keep getting this error When I load in the file
private void mnuFileLoad_Click(object sender, EventArgs e)
        {
            //todo
            //load the file and store it into the colour array file 
            //set all the colours to be unselected
            //select a file
            OpenFileDialog oFD = new OpenFileDialog();
            if (oFD.ShowDialog() == DialogResult.OK)
            {
                


                //file selected so open to read it
                StreamReader oSR = new StreamReader(oFD.OpenFile());
                int Records = int.Parse(oSR.ReadLine());
                //size Colours array
                Colours = new int[Records];
                //loop through each line to store mark in array
                for (int i = 0; i < Colours.Length; i++)
                {
                    Colours[i] = int.Parse(oSR.ReadLine());
                    

                }



            }
private void mnuFileLoad_Click(object sender, EventArgs e)
        {
            //todo
            //load the file and store it into the colour array file 
            //set all the colours to be unselected
            //select a file
            OpenFileDialog oFD = new OpenFileDialog();
            if (oFD.ShowDialog() == DialogResult.OK)
            {
                


                //file selected so open to read it
                StreamReader oSR = new StreamReader(oFD.OpenFile());
                int Records = int.Parse(oSR.ReadLine());
                //size Colours array
                Colours = new int[Records];
                //loop through each line to store mark in array
                for (int i = 0; i < Colours.Length; i++)
                {
                    Colours[i] = int.Parse(oSR.ReadLine());
                    

                }



            }
looking at this portion, I'm not sure how to set all my code to be unselected
image.png
BlazeBin - giovsrlllnke
A tool for sharing your source code with the world!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Hi need help with code for arrays in unity
C#CC# / help
3y ago
✅ help with 2D arrays
C#CC# / help
3y ago
❔ Need help with my code
C#CC# / help
3y ago